Skip to content

Instantly share code, notes, and snippets.

@kettanaito
Last active May 13, 2018 10:16
Show Gist options
  • Save kettanaito/02bb10348938caf544fcbea516f47b8f to your computer and use it in GitHub Desktop.
Save kettanaito/02bb10348938caf544fcbea516f47b8f to your computer and use it in GitHub Desktop.
React Advanced Form - Validation messages
// app/validation-messages.js
export default {
generic: {
missing: 'Please provide the required field',
invalid: 'The value you have provided is invalid'
},
type: {
email: {
missing: 'Please provide the e-mail',
invalid: ({ value }) => `The e-mail "${value}" has invalid format`
},
password: {
invalid: 'The password you entered is invalid',
rule: {
capitalLetter: 'Include at least one capital letter',
minLength: 'Password must be at least 6 characters long'
}
}
},
name: {
confirmPassword: {
rule: {
matches: 'The passwords do not match'
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment