TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Form\Utility\ValidatorUtility Class Reference
Inheritance diagram for TYPO3\CMS\Form\Utility\ValidatorUtility:
TYPO3\CMS\Core\SingletonInterface tx_form_System_Validate

Public Member Functions

 __construct ()
 
 createRule ($class, $arguments=array())
 
 addRule ($rule, $fieldName, $breakOnError=FALSE)
 
 isValid ()
 
 getMessages ()
 
 getMessagesByName ($name)
 
 hasMessage ($name)
 
 getErrors ()
 
 getErrorsByName ($name)
 
 hasErrors ($name)
 

Protected Member Functions

 getPrefix ()
 

Protected Attributes

 $rules = array()
 
 $messages = array()
 
 $errors = array()
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! Static methods for validation

Author
Patrick Broens patri.nosp@m.ck@p.nosp@m.atric.nosp@m.kbro.nosp@m.ens.n.nosp@m.l

Definition at line 22 of file ValidatorUtility.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Form\Utility\ValidatorUtility::__construct ( )

Constructor

Definition at line 48 of file ValidatorUtility.php.

Member Function Documentation

◆ addRule()

TYPO3\CMS\Form\Utility\ValidatorUtility::addRule (   $rule,
  $fieldName,
  $breakOnError = FALSE 
)

Add a rule to the rules array The rule needs to be completely configured before adding it to the array

Parameters
object$ruleRule object
string$fieldNameField name the rule belongs to
boolean$breakOnErrorBreak the rule chain when TRUE
Returns

Definition at line 84 of file ValidatorUtility.php.

References TYPO3\CMS\Form\Utility\ValidatorUtility\getPrefix().

◆ createRule()

TYPO3\CMS\Form\Utility\ValidatorUtility::createRule (   $class,
  $arguments = array() 
)

Create a rule object according to class and sent some arguments

Parameters
string$className of the validation rule
array$argumentsConfiguration of the rule
Returns
The rule object

Definition at line 68 of file ValidatorUtility.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ getErrors()

TYPO3\CMS\Form\Utility\ValidatorUtility::getErrors ( )

Returns all error messages from all rules

Returns
array

Definition at line 174 of file ValidatorUtility.php.

References TYPO3\CMS\Form\Utility\ValidatorUtility\getPrefix().

◆ getErrorsByName()

TYPO3\CMS\Form\Utility\ValidatorUtility::getErrorsByName (   $name)

Returns error messages for a single form object

Parameters
string$nameName of the form object
Returns
array

Definition at line 184 of file ValidatorUtility.php.

References TYPO3\CMS\Form\Utility\ValidatorUtility\getPrefix().

◆ getMessages()

TYPO3\CMS\Form\Utility\ValidatorUtility::getMessages ( )

Returns all messages from all rules

Returns
array

Definition at line 142 of file ValidatorUtility.php.

References TYPO3\CMS\Form\Utility\ValidatorUtility\getPrefix().

◆ getMessagesByName()

TYPO3\CMS\Form\Utility\ValidatorUtility::getMessagesByName (   $name)

Returns messages for a single form object

Parameters
string$nameName of the form object
Returns
array

Definition at line 152 of file ValidatorUtility.php.

References TYPO3\CMS\Form\Utility\ValidatorUtility\getPrefix().

◆ getPrefix()

◆ hasErrors()

TYPO3\CMS\Form\Utility\ValidatorUtility::hasErrors (   $name)

Returns TRUE when a form object has an error

Parameters
string$nameName of the form object
Returns
boolean

Definition at line 194 of file ValidatorUtility.php.

References TYPO3\CMS\Form\Utility\ValidatorUtility\getPrefix().

◆ hasMessage()

TYPO3\CMS\Form\Utility\ValidatorUtility::hasMessage (   $name)

Returns TRUE when a form object has a message

Parameters
string$nameName of the form object
Returns
boolean

Definition at line 162 of file ValidatorUtility.php.

References TYPO3\CMS\Form\Utility\ValidatorUtility\getPrefix().

◆ isValid()

TYPO3\CMS\Form\Utility\ValidatorUtility::isValid ( )

Returns TRUE when each rule in the chain returns valid When a rule has breakOnError set and the rule does not validate, the check for the remaining rules will stop and method returns FALSE

Returns
boolean True if all rules validate

Definition at line 111 of file ValidatorUtility.php.

References $result, and TYPO3\CMS\Form\Utility\ValidatorUtility\getPrefix().

Member Data Documentation

◆ $errors

TYPO3\CMS\Form\Utility\ValidatorUtility::$errors = array()
protected

Definition at line 43 of file ValidatorUtility.php.

◆ $messages

TYPO3\CMS\Form\Utility\ValidatorUtility::$messages = array()
protected

Definition at line 36 of file ValidatorUtility.php.

◆ $rules

TYPO3\CMS\Form\Utility\ValidatorUtility::$rules = array()
protected

Definition at line 29 of file ValidatorUtility.php.