NewOldMax / react-form-validator-core

Core validator component for react forms
MIT License
95 stars 44 forks source link

is equal #3

Closed skorp closed 7 years ago

skorp commented 7 years ago

isequal: for password or email confirmation

NewOldMax commented 7 years ago

Example of real usage?

skorp commented 7 years ago
render () {
const emailconfirm = 'isEqual:'+this.state.email;
return (
<Grid item xs={12} sm={4}>
  <TextField
    id="email"
    name="email"
  .......
  validators={['required', 'isEmail']}
      errorMessages={[formatMessage(formMessages.isRequired), formatMessage(formMessages.isValidEmail)]}
/>
</Grid>
<Grid item xs={12} sm={4}>

  <TextField
name="email_confirmation"
.....
validators={['required', 'isEmail',emailconfirm]}
errorMessages={[formatMessage(formMessages.isRequired), formatMessage(formMessages.isValidEmail),'does not match']}
/>
</Grid>
)
)
NewOldMax commented 7 years ago

You can achieve same behavior with matchRegexp, or define your own rules so I don't see sense for this rule