Created
July 27, 2021 16:03
-
-
Save codewithbernard/fc4645ba4226d32e3733e1ec6d7adc39 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
Person.propTypes = { | |
email: (props, propName, componentName) => { | |
// Regex to test if email is correct | |
if (!/^[^\s@]+@[^\s@]+$/.test(props[propName])) { | |
return new Error( | |
`Invalid prop "${propsName}" supplied to "${componentName}"` | |
); | |
} | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment