FaridSafi / react-native-gifted-form

📝 « One React-Native form component to rule them all »
MIT License
1.44k stars 214 forks source link

Problem with validator! #114

Open ruballos opened 6 years ago

ruballos commented 6 years ago

I use a async func to change my state.validate=true/false every on onChangeText method in a TextInputWidget. That´s work; but my problem is when I need that my validator read the state.validate....always is a prev value than the actual value! I use it for comprobe if a username exists in my BD, but if I need to comprobe if the username 'hello1989' exists, the validator return a correct response only when I type one more character: 'hello1989h' (the hello1989 user exists)....I spend two days and cant reach this....the state.validate is passing delayed to my validator. (Sorry my bad english)

<GiftedForm
    formName='newAccountForm' // GiftedForm instances that use the same name will also share the same states

    validators={{

      username: {
          validator: (args) =>{

                  return this.state.usuarioExiste; //return true or false

          },
          message: 'User unavailable!'
        }]
      },

      ...
      ...

Is posible manage externally the message from a validator ?....for example, from the onSubmit() of the form...