Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
indiscale-files-ui-react
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
indiscale-files-ui-react
Commits
46595301
Commit
46595301
authored
2 years ago
by
Jose Manuel Serrano Amaut
Browse files
Options
Downloads
Patches
Plain Diff
[REF]: Improve validation to make custom validation to complement the default validation
parent
c59382ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/files-ui/core/validation/fileValidator.ts
+12
-2
12 additions, 2 deletions
src/files-ui/core/validation/fileValidator.ts
with
12 additions
and
2 deletions
src/files-ui/core/validation/fileValidator.ts
+
12
−
2
View file @
46595301
...
...
@@ -119,16 +119,26 @@ export const validateExtFile = (
):
ExtFile
=>
{
let
extFileResult
:
ExtFile
=
{
...
extFile
};
let
errors
:
string
[]
=
[];
//TO-DO: Add extra validation for individual props even if FIle object was not given
if
(
!
extFile
.
file
)
{
return
{
...
extFileResult
}
}
//TO-DO: add "overrideValidation" prop to ignore the rest of validators like accept and maxFileSize
if
(
validator
)
{
return
{
...
extFileResult
,
...
validator
(
extFileResult
.
file
as
File
)
};
const
resultCustomValidation
:
CustomValidateFileResponse
=
validator
(
extFileResult
.
file
as
File
);
const
{
errors
:
errorsResult
}
=
resultCustomValidation
;
if
(
errorsResult
)
errors
.
push
(...
errorsResult
)
//return { ...extFileResult, ...validator(extFileResult.file as File) };
}
const
{
maxFileSize
,
accept
}
=
validatorProps
;
console
.
log
(
"
Validation
"
,
maxFileSize
,
accept
);
//check file size
const
file
:
File
=
extFile
.
file
;
if
(
maxFileSize
&&
file
.
size
>
maxFileSize
)
{
const
maxFileSizeErrorMessenger
:
FunctionLabel
=
localErrors
.
maxSizeError
as
FunctionLabel
;
...
...
@@ -142,7 +152,7 @@ export const validateExtFile = (
}
const
isValid
:
boolean
=
errors
.
length
===
0
;
extFileResult
=
{
...
extFileResult
,
valid
:
isValid
,
errors
:
!
isValid
?
errors
:
undefined
};
console
.
log
(
"
validation extFileResult
"
,
extFileResult
);
console
.
log
(
"
validation extFileResult
"
,
extFileResult
);
return
extFileResult
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment