Created
April 11, 2023 01:19
-
-
Save mathiasgheno/617a312306e03d0d1d50d8c97b936025 to your computer and use it in GitHub Desktop.
This file contains 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
const hasMoreCharactersThan = (desired) => (value) => { | |
const size = value?.length; | |
if(size < desired) { | |
throw new Error(`Value is not more than ${desired} characters`); | |
} | |
return value; | |
} | |
const isValidDescription = hasMoreCharactersThan(100); | |
const isValidEmail = hasMoreCharactersThan(10); | |
isValidEmail('mathiasgheno@gmail.com') // ok | |
isValidDescription('My description') // Error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment