Closed lukejagodzinski closed 7 years ago
Needs to have a null check on strings prior to asserting the length of the string. This occurs when when a value is not provided in clonedArgs[0] in the GiftedFormManager. Specifically, the clonedArgs[0] value is null. As a result, the validator library throws an exception when validation is applied.
To temporarily work around this issue, you can add a try/catch statement in the GiftedFormManager, like so:
try {
isValid = validatorjs[validate[i].validator].apply(null, clonedArgs);
result.push({
validator: validate[i].validator,
isValid,
message,
value: clonedArgs[0],
title: title || k,
});
} catch(exception) {
console.log(exception);
}
Keep in mind that this is just a temporary workaround and not a permanent solution. It does allow the validation to work on the form and prevents a redbox on submit.
+1
UPDATE: One solution is to ocupy the default values with empty strings eg.
defaults={{
password:'',
emailAddress:'',
}}
This is a verified issue, thank you! A PR would be welcome if anyone wants to tackle this.
Fixes the validation errors. I'm still having issues with the date being reflected properly when selected (not sure if this is another issue or related at the moment).
@frmdstryr I've fixed it and released v0.0.15, please try again :) The date seems to be working for me on the example app.
Yep, working good now. Thanks!
When I try to submit form without defaults and with empty fields I get the
This library (validator.js) validates strings only
error. I assume that this bug is caused by form values beingundefined
on form init. So after not focusing or changing form input it will try to validateundefined
values. Solution could be copying all inputs' values at form init.