How would I validate my confirmPassword field with the tcomb-form-native library?
E-mail and password fields are quite trivial, I wouldn't know how to compare to the existing value of another field in the model though.
Here's my code.
const Email = t.refinement(t.String, (email) => {
const reg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
return reg.test(email);
});
const Password = t.refinement(t.String, (password) => {
const reg = /^(?=\S+$).{8,}$/;
return reg.test(password);
});
const RegistrationData = t.struct({
email: Email,
password: Password,
confirmPassword: t.String // Need some equality check
});
I've investigated the docs https://github.com/gcanti/tcomb-form-native#disable-a-field-based-on-another-fields-value but I can't make sense of it.