valitron | Valitron is a simple, elegant, stand-alone validation library with NO dependencies | Validation library
kandi X-RAY | valitron Summary
kandi X-RAY | valitron Summary
Valitron is a simple, minimal and elegant stand-alone validation library with NO dependencies. Valitron uses simple, straightforward validation methods with a focus on readable and concise syntax. Valitron is the simple and pragmatic validation library you've been looking for.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Validate a credit card
- Add a validation rule
- Validate the values .
- Get a part of the data
- Check if a field is required
- Validate that a field is required
- Validate that a string contains a value .
- Add an error message
- Map field rules
- Check and set error message
valitron Key Features
valitron Examples and Code Snippets
Community Discussions
Trending Discussions on valitron
QUESTION
I've been trying to add a custom rule to the Valitron validator, but without success. The documentation is here
My own custom rule didn't work, so I tried using the simplest possible implementation with the actual example from the documentation, and the rule still doesn't trigger. Here is what I have:
...ANSWER
Answered 2020-May-12 at 18:40Okay, I figured it out. It seems a bit obvious in retrospect, but I've been working on this for a couple of days. The problem is that 'other_building' is blank, and is allowed to be blank (e.g. not required). Therefore the validator is passing over it and never checking the rule. If you put in a non-blank value for 'other_building', it works. It also works if you leave it blank, but add a rule that 'other_building' is required. If you don't want the field to be required, but you also want the rule to run every time 'other_building' is in the data, even if the value is blank, you need to add an 'optional' rule, which states that "Value does not need to be included in data array. If it is however, it must pass validation."
So this works:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install valitron
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page