Closed benjamingeorge closed 7 years ago
I checked my package's code but I think it is ok, I don't call that function directly in my code. It seems related to the validatorjs package because it handles the execution of that function. I don't know if it is a bug or it deliberately forces you to use the required
rule keyword to check the presence of the value. We should open the issue there on their repo.
ok thanks. I went the custom validator route and that seemed solve my issue.
@benjamingeorge what do you mean?
something like
{
type: 'text',
name: "shortName",
label: "Short Name",
placeholder: "Short Name",
rules: "string|max:60",
validators: [requireIfMaxExceeds('name', 60)],
options: {
validateOnChange: true,
}
}
Great!
When creating a custom rule, they only run if there is a value in the field. Which is a problem for custom rules that are of the "require_if" type. Creating a simple mock custom rule using the "required" code you will see that in the console "validating" is only logged if there is a value in the input field, not empty.
then using it