jeffraux / react-native-validate-form

A simple yet customizable (to some extent) form validation in React Native
MIT License
8 stars 5 forks source link

How to validate new password and confirm password? #7

Open sraza295 opened 4 years ago

sraza295 commented 4 years ago

const required = value => (value ? undefined : ' This is a required field.'); const confirmPassword = value => (value!=required ? undefined : ' Did not match.');

       <Field
          customStyle={styles.inputBox}
          required
          component={InputField}
          validations={[required]}
          name="newPassword"
          value={this.state.newPassword}
          onChangeText={val => this.setState({newPassword: val})}
          placeholder="New Password"
          secureTextEntry={true}
        />

        <Field
          customStyle={styles.inputBox}
          required
          component={InputField}
          validations={[confirmPassword]}
          name="confirmPassword"
          value={this.state.confirmPassword}
          onChangeText={val => this.setState({confirmPassword: val})}
          placeholder="Confirm Password"
          secureTextEntry={true}
        />