|Classes of Jonas Earendel||>||Simple Form Validator||>||README.md||>||Download|
The purpose of SimpleFormValidator is to make user input validation secure, simple and fast.
No external rule declarations are necessary, or even possible.
SimpleFormValidator will instead extract the rules from the HTML using PHP's native DOMDocument class.
Just make sure you have valid HTML5 code, and it will work.
Three ingredients are needed to make it work:
A BASIC EXAMPLE
The smallest example imaginable:
>$_POST['your_email'] will be validated as an e-mail address. $_POST['your_email'] cannot be left empty. $_POST['repeat_email'] must match $_POST['your_email'], whether empty or not.
So, the user has entered a valid username and password, but they aren't correct.
That's when custom errors (triggerCustomError()) come in handy.
If for instance a user is logged in and wants to send an e-mail, you can pre-populate the form. (This saves a lot of time during development.)
The base class does not have that many validators, just the ones I've had use for lately, but that is not the end of the story.
Create your own class, extending SimpleFormValidator, and add the validators you want. The existing ones can all be found in the original's constructor, if you need hints.
I do not recommend editing SimpleFormValidator directly, since there may be updates in the future.