Closed amakhrov closed 8 years ago
We want to add new rule "any" in future versions of LIVR
Thanks. Passing any rule probably works as a temporary workaround - but it kind breaks the semantics.
Why not allow an empty list of validations ([]
) for such cases?
I am going to update the spec (not sure will it be empty array or "any" rule) but I am not sure that the update matches your need. For example, if you say {fieldName: []} it means that user can pass string or array or hash. But in most cases developers want any string but not array or hash. Can you describe your case?
@koorchik you're right, in my case it should be an arbitrary string (even a missing field) - but not e.g. an array.
Hi, similar issue here. I need a field that can never fail validation. Any thoughts on how to do that? The default value is an empty string, but there's potential for other things to be stored in there too.
@Sandvich, lock at the discussion above, answer is here.
@SDSWanderer Yeah, I'm currently using min_length as suggested. That crashes when you try and put an integer in there, however, as integers have no length (at least not in python).
@Sandvich, ok, you can register you own rule (any
for example). Rule implementation is trivial, just always return empty function.
Great, thanks!
"string" rule will be added to the LIVR 2.0 instead of "any". Will match any string.
My form allows arbitrary string value for one of the fields. And this field is optional (not required). How can I configure a LIVR rule for that? I tried to pass
'fieldName' => NULL
and'fieldName' => []
- both trigger an error after callingvalidate()
:Exception: Rule [] not registered
andUndefined index: