Skip to content

Instantly share code, notes, and snippets.

@codewithbernard
Created July 27, 2021 16:03
Show Gist options
  • Save codewithbernard/fc4645ba4226d32e3733e1ec6d7adc39 to your computer and use it in GitHub Desktop.
Save codewithbernard/fc4645ba4226d32e3733e1ec6d7adc39 to your computer and use it in GitHub Desktop.
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