Checks if value is between min and max length

If only one numeric value is passed as argument, this value is interpreted as min length value.

Supported arguments are:

Formagic_Rule_StringLength::__construct(array(
     'min' => (int)$min,
     'max' => (int)$max,
     'messages' => array(
         'min' => (string)$errorMessage,
         'min' => (string)$errorMessage,
         'between' => (string)$errorMessage,
     )
));
Formagic_Rule_StringLength::__construct(array('min' => (int)$min, 'max' => (int)$max));

category Formagic
package Rule
subpackage RangeComparsion
author Florian Sonnenburg
author Marc Schrader
copyright Copyright (c) 2007-2011 Florian Sonnenburg
version $Id: StringLength.php 160 2012-04-02 20:18:14Z meweasle $

 Methods

Constructor

__construct(array $arguments) 
Inherited

The default error message that is displayed if the rule is violated can be overwritten by $errorMessage.

see \self::_init()
inherited_from \Formagic_Rule_Abstract::__construct()
inherited_from \Formagic_Rule_RangeComparsion_Abstract::__construct()

Parameters

$arguments

array

The rule options.

Returns translated error message of rule

getMessage() : string
Inherited

inherited_from \Formagic_Rule_Abstract::getMessage()
inherited_from \Formagic_Rule_RangeComparsion_Abstract::getMessage()

Returns

stringMessage string

Returns rule type identification string.

getName() : string
Inherited

inherited_from \Formagic_Rule_Abstract::getName()
inherited_from \Formagic_Rule_RangeComparsion_Abstract::getName()

Returns

stringThe rule name

Not supported by range comparison rules.

setMessage(string $message) : \Formagic_Rule_Abstract
Inherited

Usually a rule will have one error message string that is used if the validation fails. If neccessary, Formagic_Rule_Abstract::_errorMessage can hold other variables, eg. an array of error messages for different outcomes of the validation process.

Implements a fluent interface pattern.

inherited_from \Formagic_Rule_RangeComparsion_Abstract::setMessage()

Parameters

$message

string

New message string

Exceptions

\Formagic_Exception

Returns

Sets messages array

setMessages(array $messages) : \Formagic_Rule_RangeComparsion_Abstract
Inherited

inherited_from \Formagic_Rule_RangeComparsion_Abstract::setMessages()

Parameters

$messages

array

Array of messages

Returns

Performs rule check

validate(string $value) : boolean
Inherited

Length rule checks if value is between min and max length. The validation method depends on $this->_type.

inherited_from \Formagic_Rule_RangeComparsion_Abstract::validate()

Parameters

$value

string

The item to checked

Returns

booleanThe validation result

Evaluate between range (including limits).

_execBetween(integer $range) : boolean
Inherited

inherited_from \Formagic_Rule_RangeComparsion_Abstract::_execBetween()

Parameters

$range

integer

Range value

Returns

booleanEvaluation result

Evaluate maximum range (lessers or equals).

_execMax(integer $range) : boolean
Inherited

inherited_from \Formagic_Rule_RangeComparsion_Abstract::_execMax()

Parameters

$range

integer

Upper limit

Returns

booleanEvaluation result

Evaluate minimum range (greater or equals).

_execMin(integer $range) : boolean
Inherited

inherited_from \Formagic_Rule_RangeComparsion_Abstract::_execMin()

Parameters

$range

integer

Lower limit

Returns

booleanEvaluation result

Returns a translates message string.

_getMessage(string $key) : string
Inherited

inherited_from \Formagic_Rule_RangeComparsion_Abstract::_getMessage()

Parameters

$key

string

Message type

Returns

stringTranslated filled message

Returns range check value.

_getRange(string $value) : integer

Parameters

$value

string

Item value

Returns

integerRange check value

Allows subclass initialization.

_init(array $arguments) : void
Inherited

Allowed options for this rule are:

(integer)min:
Minimal length to be checked (optional, defaults to 0)
(integer)max:
Maximal length to be checked (optional, defaults to 0)

Will throw an exception, if neither "min" nor "max" option provided.

inherited_from \Formagic_Rule_RangeComparsion_Abstract::_init()

Parameters

$arguments

array

Array of arguments passed to __construct()

Checks if value is not entered by a user or if the field has not been assigned to the form.

_isNoUserValue(\$value $value) : boolean
Inherited

The value 0 (zero) for example could be something the user entered willingly and would be skipped from rule checks when using empty().

inherited_from \Formagic_Rule_Abstract::_isNoUserValue()
inherited_from \Formagic_Rule_RangeComparsion_Abstract::_isNoUserValue()

Parameters

$value

\$value

mixed Value to be checked

Returns

boolean

 Properties

 

The maximal length

$_max : integer
Inherited

inherited_from \Formagic_Rule_RangeComparsion_Abstract::$$_max
 

Message string

$_message : string
Inherited

inherited_from \Formagic_Rule_Abstract::$$_message
inherited_from \Formagic_Rule_RangeComparsion_Abstract::$$_message
 

Default error messages

$_messages : array

 

The minimal length

$_min : integer
Inherited

inherited_from \Formagic_Rule_RangeComparsion_Abstract::$$_min
 

Rule type identifier.

$_name : string
Inherited

inherited_from \Formagic_Rule_Abstract::$$_name
inherited_from \Formagic_Rule_RangeComparsion_Abstract::$$_name