Intro
Leaf v1.5.0 has introduced a new Leaf Form module which is the replacement for Simple Validation from v1.2.0 which was discontinued in v1.3.0. Leaf Form contains methods to handle input from the user...
To use Leaf Form, you simply have to import it:
Leaf Form Methods
sanitizeInput
sanitizeInput offers basic security for input data, i.e. sanitizing input against SQL injection.
isEmpty
isEmpty checks a field to see if it's empty. If it's empty, it adds an error to Leaf Form's errors. It takes in 3 parameters: the data to test, the name of that data and the error message if it's empty(optional).
isNull
isNull checks a field to see if it's null. If it's null, it adds an error to Leaf Form's errors. It takes in 3 parameters: the data to test, the name of that data and the error message if it's empty(optional).
Validate new in v1.5.0
Leaf now provides a much simpler way to validate a parameter using Leaf Forms. In one line, you can create a bunch of rules to validate a parameter with. Validate simply makes sure that the passed selected parameters pass these validation tests. It's never been simpler😎
Parameters which fail the form validation are saved in the form's errors which can be accessed with errors()
This is a list of all supported validate rules
- required
- number
- textOnly
- validUsername
- NoSpaces
errors
Remember we talked about Leaf Form errors? Leaf Form holds errors for all failed tests, you get all these errors back with returnErrors