Skip to content

Instantly share code, notes, and snippets.

@selvagsz
Created November 16, 2016 13:59
Show Gist options
  • Save selvagsz/755ddf53255d9089754de147405c7da9 to your computer and use it in GitHub Desktop.
Save selvagsz/755ddf53255d9089754de147405c7da9 to your computer and use it in GitHub Desktop.
redux-form-validator
import { reduxForm } from 'redux-form'
import { validator } from 'rzp/utils/validator'
@reduxForm({
name: 'formName',
validate: validator({
firstName: {
presence: true,
message: 'First name can\'t be blank',
},
email: {
presence: true,
type: 'email', // supported types date,number,string
messages: {
presence: 'Email can\'t be blank',
type: 'Email is invalid'
},
length: {
min: 3,
max: 10,
message: 'should be between 3 & 10',
messages: {
min: 'Can\'t be less than 3 chars',
max: 'Can\'t be more than 10 chars'
}
}
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment