TwistPHP Documentation

test

File path: dist/twist/Core/Models/Validate/Validator.model.php
Namespace: Twist\Core\Models\Validate
Extends:

testValidate an array of data against an array of checks. Very useful for validating $_GET and $_POST arrays.
The checks array should consist of a key (the field name you want to check) and an array of checks consisting of any of the below options:
blank = 1|0
type = compare|email|url|ip|boolean|float|integer|string|telephone|postcode
required = 1|0
Note: When checking a multi-dimensional array the key can contain '/' for eg. 'user/name' for the array $arrData['user']['name']
Return Keys per field
status - If the field passed the test
type - Contains the type of problem encountered pass|blank|invalid|missing
message - The message contains a basic human readable description of the problem

Parameters

Name Type Description
$arrDataarrayn/a

Return Values

void — No return information has been documented for this function.

Example

<?php
//Set the variables for the example
$arrData = array(=> 'foo'=> 'bar');

//Call the function test with the example vars
$resValidator = new \Twist\Core\Models\Validate\Validator();
$resValidator -> test($arrData);