Documentation

FilterValidationRule
in package
implements ValidationRule

A filter based validation rule allows you to use premade PHP filters to validate your content. Please note that a filter that sanitizes may cause unwanted behavior or unexpected ones.

Tags
author

César de la Cal cesar@magic3w.com

last-revision

2013-11-12

Interfaces, Classes and Traits

ValidationRule
Classes implementing this one indicate their ability to test a variable and verify that it's contents are according to what was expected.

Table of Contents

$extendedMessage  : string
Additional information given to the user in case the validation did not succeed. This message can hold additional infos on how to solve the error.
$filter  : int
The filter being applied. This is one of the <code>FILTER_VALIDATION_*</code> constants defined in PHP's core, you can use any of those to place here.
$message  : string
A message the validation error generated by this object should carry to give the end user information about the reason his input was rejected.
__construct()  : mixed
Creates a new validation rule that relies on PHP's filters. You need to pass one of the VALIDATION_FILTER_* constants to it so it works. Many of this functions provide useful tools for quick validation of common tasks.
test()  : ValidationError|bool
Tests a value with this validation rule. Returns the errors detected for this element or boolean false on no errors.

Properties

$extendedMessage

Additional information given to the user in case the validation did not succeed. This message can hold additional infos on how to solve the error.

private string $extendedMessage

$filter

The filter being applied. This is one of the <code>FILTER_VALIDATION_*</code> constants defined in PHP's core, you can use any of those to place here.

private int $filter

$message

A message the validation error generated by this object should carry to give the end user information about the reason his input was rejected.

private string $message

Methods

__construct()

Creates a new validation rule that relies on PHP's filters. You need to pass one of the VALIDATION_FILTER_* constants to it so it works. Many of this functions provide useful tools for quick validation of common tasks.

public __construct(int $filter, string $message[, string $extendedMessage = '' ]) : mixed
Parameters
$filter : int

One of the VALIDATION_FILTER_* constants

$message : string

The message returned when an error is found

$extendedMessage : string = ''

Additional error information

Return values
mixed

test()

Tests a value with this validation rule. Returns the errors detected for this element or boolean false on no errors.

public test(mixed $value) : ValidationError|bool
Parameters
$value : mixed

The value tested.

Return values
ValidationError|bool

A validation error or boolean on success

Search results