score:0

validator = new FormValidator([
        {
            field: 'userName',
            method: 'isEmpty',
            validWhen: false,
            message: 'Email is required.'
        },
        {
            field: 'password',
            method: 'isEmpty',
            validWhen: false,
            message: 'Password is required.'
        },
        {
            field: 'confirmPassword',
            method: 'isEmpty',
            validWhen: false,
            message: 'Password confirmation is required.'
        },
        {
            field: 'confirmPassword',
            method: this.passwordMatch,   // notice that we are passing a custom function here
            validWhen: true,
            message: 'Password and password confirmation do not match.'
        }
    ]);


    <TextField outlined label='User Name' className="w-100 mb-1 mt-2 help-block"
      helperText={<HelperText validation>{validation.userName.message}</HelperText>}>
   <Input isValid={!validation.userName.isInvalid} value={this.state.userName || ''} name="userName" onChange={this.handleInputChange} />
</TextField>

Related Query

More Query from same tag