We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
I am using Final Form. I have an e-mail field that is optional.
How would you validate only if the user tried to enter a wrong e-mail? I have succeeded to do this but I didn`t like the solution:
import * as vld from 'redux-form-validators';
<Field name="email" label="E-mail de Contato" placeholder="Deixe seu e-mail" component={TextInputField} validate={emailIfNotEmpty} />
The custom validator code is like this:
const emailIfNotEmpty = (value, allValues, meta) => { if (meta.dirty) { return vld.email()(value); } }
Can you suggest a better approach?
Kind Regards, Mário
The text was updated successfully, but these errors were encountered:
have you checked the conditional validations? You can check the args passed by if and unless. I think the third arg should be meta with Final Form.
if
unless
meta
Sorry, something went wrong.
I tested right now and I'm just receiving values and value. The props and name parameters remain undefined.
values
value
props
name
undefined
No branches or pull requests
Hello,
I am using Final Form. I have an e-mail field that is optional.
How would you validate only if the user tried to enter a wrong e-mail? I have succeeded to do this but I didn`t like the solution:
import * as vld from 'redux-form-validators';
<Field name="email" label="E-mail de Contato" placeholder="Deixe seu e-mail" component={TextInputField} validate={emailIfNotEmpty} />
The custom validator code is like this:
const emailIfNotEmpty = (value, allValues, meta) => { if (meta.dirty) { return vld.email()(value); } }
Can you suggest a better approach?
Kind Regards,
Mário
The text was updated successfully, but these errors were encountered: