Skip to content

Commit 1c3cee9

Browse files
committed
[REF]: Add useful comments on validate.util.ts file
1 parent 216ab11 commit 1c3cee9

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/components/dropzone/components/utils/validation.utils.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ export const separateAccept = (accept: string | undefined): string[] => {
3131
return commaSeparatedAccpet;
3232
}
3333
/**
34-
*
34+
* Checks whether a file is valid or not given an array of file extentions and mime types
35+
* e.g. accept = [".doc", ".docx", ".xml", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]
3536
* @param accept the array of strings accept items
3637
* @param file a File object to be evaluated
37-
* @returns
38+
* @returns true if the mime type file is included in the accept param
3839
*/
3940
export const validateAccept = (accept: string[], file: File): boolean => {
4041
let valid: boolean = false;
@@ -157,7 +158,7 @@ export abstract class FileIdGenerator {
157158
* Random integer between min (included) and max (excluded)
158159
* @param min
159160
* @param max
160-
* @returns
161+
* @returns a random number between min (included) and max (excluded)
161162
*/
162163
function getRandomInt(min: number, max: number): number {
163164
return Math.floor(Math.random() * (max - min)) + min;
@@ -200,10 +201,10 @@ export const makeSynthticFileValidate = (
200201
uploadMessage?: string
201202
): FileValidated => {
202203
//if valid, naturally, can be uploaded
203-
let errors: string[]|undefined = [];
204+
let errors: string[] | undefined = [];
204205
let newUpoadStatus = uploadStatus || getRandomUploadStatus();
205206

206-
let customUploadMessage: string|undefined = uploadMessage || "";
207+
let customUploadMessage: string | undefined = uploadMessage || "";
207208
if (valid) {
208209
//we can decide according to upload status
209210
if (!uploadMessage) {
@@ -224,12 +225,12 @@ export const makeSynthticFileValidate = (
224225
//now make a File Validated instance
225226
const newFileValidated: FileValidated = {
226227
id: FileIdGenerator.getNextId(),
227-
valid:valid,
228-
file:file,
228+
valid: valid,
229+
file: file,
229230
uploadStatus: newUpoadStatus,
230231
uploadMessage: customUploadMessage,
231-
errors:errors
232-
}
232+
errors: errors
233+
};
233234
return newFileValidated;
234235
}
235236
/**

0 commit comments

Comments
 (0)