What is the simplest (cleaner) way to validate optional fields using Kohana 3.2 ORM?
- Validates only if the field has something, after trim filter, if it is possible.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, maybe (:P) I’ve forgot the differences between mandatory fields and optional fields:
The second one, the optional field ‘longitude’ is only triggered if has something that is not accepted by Valid::is_coordinate.
The first one, the mandatory field, is controlled by ‘not_empty’, or something with similar behavior.
About the filter, ORM filters are processed before the rules, so something like this is enough:
I’m tested myself right now, and is working nicely.