File src/addon/POSTValidator.php
class Lia\Addon\POSTValidator
When activated, it unsets $_POST and then only re-sets it after validation
See source code at /src/addon/POSTValidator.php
Constants
Properties
-
public string $fqn = 'lia:server.postvalidator'; -
public readonly \Lia\Utility\InputValidator $validator; -
protected array $post;$_POSTis copied to here
Methods
-
static public function activate(\Lia $lia)Enable for the given instance of liaison. Sets$_POST = []. Re-populates$_POSTwhen validations are successful. -
static public function activateForPackage(\Lia\Package $package)Hooks into \Lia\Hooks::ROUTES_FILTERED, to activate only if the given package is requested by the route. -
static public function from(\Lia $lia): selfstatic -
public function __construct(\Lia\Package $package=null) -
public function dump()Print all $_POST values andexit -
public function validate(string $key, arraystringnull $rules = null, callable $validation_function null): boolCheck if the given entry matches expectations. You may pass BOTH$rulesAND$validation_function, or you may pass just one (your choice). If you pass both, then both$rulesAND$validation_functionMUST returnTRUEfor validation to pass. If you pass only$key, then it is considered valid as long as$keyis set in$_POST. When validation passes,$_POST[$key]is populated with the validated value.