Created
July 15, 2022 16:25
-
-
Save Octagon-simon/5668ee9f53380e4aa83407344c5ef46e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //create an array that will store the image file type | |
| const requiredTypes = ["image/jpg", "image/jpeg", "image/png"]; | |
| //store error | |
| const valError = []; | |
| //loop through object and compare type | |
| for (let file of fileInpFiles){ | |
| if ( !requiredTypes.includes( file.type ) ){ | |
| valError.push(file.name); | |
| } | |
| } | |
| //check if there's a validation error | |
| if( valError.length !== 0 ){ | |
| valError.forEach( f => { | |
| console.log(`${f} is not an image file`); | |
| } ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment