Wikimedia SlimApp
Common classes to help with creating an application using the Slim micro framework and Twig template engine.
|
Collect and validate user input. More...
Public Member Functions | |
__construct ( $logger=null) | |
expect ( $name, $filter, $options=null) | |
Add an input expectation. | |
expectBool ( $name, $options=null) | |
requireBool ( $name, $options=null) | |
expectBoolArray ( $name, $options=null) | |
requireBoolArray ( $name, $options=null) | |
expectTrue ( $name, $options=null) | |
requireTrue ( $name, $options=null) | |
expectTrueArray ( $name, $options=null) | |
requireTrueArray ( $name, $options=null) | |
expectEmail ( $name, $options=null) | |
requireEmail ( $name, $options=null) | |
expectEmailArray ( $name, $options=null) | |
requireEmailArray ( $name, $options=null) | |
expectFloat ( $name, $options=null) | |
requireFloat ( $name, $options=null) | |
expectFloatArray ( $name, $options=null) | |
requireFloatArray ( $name, $options=null) | |
expectInt ( $name, $options=null) | |
requireInt ( $name, $options=null) | |
expectIntArray ( $name, $options=null) | |
requireIntArray ( $name, $options=null) | |
expectIp ( $name, $options=null) | |
requireIp ( $name, $options=null) | |
expectIpArray ( $name, $options=null) | |
requireIpArray ( $name, $options=null) | |
expectRegex ( $name, $re, $options=null) | |
requireRegex ( $name, $re, $options=null) | |
expectRegexArray ( $name, $re, $options=null) | |
requireRegexArray ( $name, $re, $options=null) | |
expectUrl ( $name, $options=null) | |
requireUrl ( $name, $options=null) | |
expectUrlArray ( $name, $options=null) | |
requireUrlArray ( $name, $options=null) | |
expectString ( $name, $options=null) | |
requireString ( $name, $options=null) | |
expectStringArray ( $name, $options=null) | |
requireStringArray ( $name, $options=null) | |
expectAnything ( $name, $options=null) | |
requireAnything ( $name, $options=null) | |
expectAnythingArray ( $name, $options=null) | |
requireAnythingArray ( $name, $options=null) | |
expectInArray ( $name, $valids, $options=null) | |
requireInArray ( $name, $valids, $options=null) | |
expectInArrayArray ( $name, $valids, $options=null) | |
requireInArrayArray ( $name, $valids, $options=null) | |
expectDateTime ( $name, $format, $options=null) | |
Add an input expectation for a DateTime object. | |
requireDateTime ( $name, $format, $options=null) | |
validate ( $vars=null) | |
Validate the provided input data using this form's expectations. | |
get ( $name) | |
getValues () | |
getErrors () | |
hasErrors () | |
Static Public Member Functions | |
static | urlEncode ( $parms) |
Make a URL-encoded string from a key=>value array. | |
static | qsMerge ( $params=[]) |
Merge parameters into current query string. | |
static | qsRemove ( $params=[]) |
Remove parameters from current query string. | |
Protected Member Functions | |
customValidationHook () | |
Stub method that can be extended by subclasses to add additional validation logic. | |
Static Protected Member Functions | |
static | required ( $options) |
Ensure that the given options collection contains a 'required' key. | |
static | wantArray ( $options) |
Ensure that the given options collection contains a 'flags' key that requires the input to be an array. | |
Protected Attributes | |
$logger | |
$params = [] | |
$values = [] | |
$errors = [] | |
Collect and validate user input.
Wraps PHP's built-in filter_var_array function to collect GET or POST input as a collection of sanitized data.
Wikimedia\Slimapp\Form::__construct | ( | $logger = null | ) |
LoggerInterface | $logger | Log channel |
Wikimedia\Slimapp\Form::expect | ( | $name, | |
$filter, | |||
$options = null ) |
Add an input expectation.
Allowed options:
string | $name | Parameter to expect |
int | $filter | Validation filter(s) to apply |
array | $options | Validation options |
Wikimedia\Slimapp\Form::expectAnything | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectAnythingArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectBool | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectBoolArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectDateTime | ( | $name, | |
$format, | |||
$options = null ) |
Add an input expectation for a DateTime object.
string | $name | Parameter to expect |
string | $format | Expected date/time format |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectEmail | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectEmailArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectFloat | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectFloatArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectInArray | ( | $name, | |
$valids, | |||
$options = null ) |
string | $name | Parameter to expect |
array | $valids | Valid values |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectInArrayArray | ( | $name, | |
$valids, | |||
$options = null ) |
string | $name | Parameter to expect |
array | $valids | Valid values |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectInt | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectIntArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectIp | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectIpArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectRegex | ( | $name, | |
$re, | |||
$options = null ) |
string | $name | Parameter to expect |
string | $re | Regular expression |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectRegexArray | ( | $name, | |
$re, | |||
$options = null ) |
string | $name | Parameter to expect |
string | $re | Regular expression |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectString | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectStringArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectTrue | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectTrueArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectUrl | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::expectUrlArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to expect |
array | $options | Additional options |
Wikimedia\Slimapp\Form::get | ( | $name | ) |
string | $name | Parameter name |
Wikimedia\Slimapp\Form::getErrors | ( | ) |
Wikimedia\Slimapp\Form::getValues | ( | ) |
Wikimedia\Slimapp\Form::hasErrors | ( | ) |
|
static |
Merge parameters into current query string.
array | $params | Parameter array |
|
static |
Remove parameters from current query string.
array | $params | Parameters to remove |
Wikimedia\Slimapp\Form::requireAnything | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireAnythingArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireBool | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireBoolArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
|
staticprotected |
Ensure that the given options collection contains a 'required' key.
array | $options |
Wikimedia\Slimapp\Form::requireDateTime | ( | $name, | |
$format, | |||
$options = null ) |
string | $name | Parameter to require |
string | $format | Expected date/time format |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireEmail | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireEmailArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireFloat | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireFloatArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireInArray | ( | $name, | |
$valids, | |||
$options = null ) |
string | $name | Parameter to require |
array | $valids | Valid values |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireInArrayArray | ( | $name, | |
$valids, | |||
$options = null ) |
string | $name | Parameter to require |
array | $valids | Valid values |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireInt | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireIntArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireIp | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireIpArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireRegex | ( | $name, | |
$re, | |||
$options = null ) |
string | $name | Parameter to require |
string | $re | Regular expression |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireRegexArray | ( | $name, | |
$re, | |||
$options = null ) |
string | $name | Parameter to require |
string | $re | Regular expression |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireString | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireStringArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireTrue | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireTrueArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireUrl | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
Wikimedia\Slimapp\Form::requireUrlArray | ( | $name, | |
$options = null ) |
string | $name | Parameter to require |
array | $options | Additional options |
|
static |
Make a URL-encoded string from a key=>value array.
array | $parms | Parameter array |
Wikimedia\Slimapp\Form::validate | ( | $vars = null | ) |
Validate the provided input data using this form's expectations.
array | $vars | Input to validate (default $_POST) |
|
staticprotected |
Ensure that the given options collection contains a 'flags' key that requires the input to be an array.
array | $options |