Skip to content

Instantly share code, notes, and snippets.

@kettanaito
Last active April 22, 2018 09:33
Show Gist options
  • Save kettanaito/c08530c233134d2a77712120affbd72f to your computer and use it in GitHub Desktop.
Save kettanaito/c08530c233134d2a77712120affbd72f to your computer and use it in GitHub Desktop.
React Advanced Form - Validation rules
// src/app/validation-rules.js
import isEmail from 'validator/lib/isEmail';
export default {
type: {
email: ({ value }) => isEmail(value),
password: {
capitalLetter: ({ value }) => /[A-Z]/.test(value),
oneNumber: ({ value }) => /[0-9]/.test(value),
minLength: ({ value }) => (value.length > 5)
}
},
name: {
confirmPassword: {
matches: ({ value, get }) => {
return (value === get(['userPassword', 'value']);
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment