
Sebastian Schlapkohl - 2011-08-21 16:46:13 -
In reply to message 1 from Michael Reid
Theoretically that should be possible. You could include the class htmlform.formvalidator.class.php and use it stand alone since as far as I can see the class has no forced external dependencies to the package, except for the tools class which should lie next to the validator class.
However you would practicall have to do by hand what the framework normally performs by itself.
This would be a rough use case:
require_once 'htmlform/htmlform.formvalidator.class.php';
$isFieldXyValid = FormValidator::get()
->setValue($_POST['myfieldname'])
->setNotEmpty()
->setRangeLength(array(1, 10))
->setDigits()
->process()
;
After this the var should contain a boolean telling you if your value is valid according to the set rules.
I never used the validator this way, but in this should indeed work quite well :D
For your plan I would recommend to write a small validation wrapper to streamline validation such as:
$isResultsetValid = ValidationWrapper::get()
->addValidator(FormValidator::get()->etc.)
->addValidator(FormValidator::get()->etc.)
->validateAll()
;
If you get my idea.
Good luck!