In this tutorial we will learn how to use redux form validation in react native.
First of all, just delacre const validate for validations. inside that const create an empty const error for errors:
Now create input for first name:
After input for first name we should add if-else condition to check that first name is empty or filled:
with value check validation, we will add else-if condition to check that first name' length: (maximum 7)
at the end, we need return our errors const:
First of all, just delacre const validate for validations. inside that const create an empty const error for errors:
const validate = values =>{
const errors = {};
}
Now create input for first name:
<Field name="fname"
component={myFields}
label="First name"/>
After input for first name we should add if-else condition to check that first name is empty or filled:
if(!values.fname) {
errors.fname= "please fill the fname";
}
with value check validation, we will add else-if condition to check that first name' length: (maximum 7)
else if(values.fname.length >7){
errors.fname = "we need first name maximum 7";
}
at the end, we need return our errors const:
return errors;