PHP Класс Controller_Validator_Abstract, atk4

If you are writing your own validator rules to a very specific objects, you can use extend either this class or Validator_Basic. NOTE: How to write rules: Do not attempt to put all the rules for a single field on a line. Many rules will change the value of acumulator, so please add as many rules as necessary is(array( 'name|len|gt|20', 'name|!rude', 'name|to_ucfirst', )); Finally - you can add one validator inside another to extends it's rules.
Наследование: extends AbstractController
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$acc Next are system fields, do not access when in doubt.
$active_field Name of the field which is currently beind processed.
$alias $alias['mandatory']='required'; $alias['must_have']='required';
$bail_out
$caption
$cast
$consumed
$current_ruleset
$custom_error
$custom_hook Call this to set a different hook when rules are going to be applied. By default you have to call now() on() used by default for when validator is added, however if you call it manually (avoiding 3rd argument) it will override the default hook. This is done to avoid double-validation
$default_exception
$has_hook
$prefix When transformivg value (such as len) - will contain a modifier to the error message.
$rules Each ruleset is broken down by field and is stored in this array in a normal form. You can get rules for a particular field by calling $this->getRules(field);.
$source Validator can check either a model, array, form or any other object as long as it supports array_access. If you are using Model then you can use some additional functionality foreach selecting fields.

Открытые методы

Метод Описание
applyRules ( $field, $ruleset ) This is the main body for rule processing.
applyRulesets ( ) Go through the list of defined rules and call the corresponding filters and convertors.
expandFieldDefinition ( $field_definition, &$normalized_rules ) Provided with a multiple field definition, this will convert them into an array.
fail ( ) {{{ Methods which are called by the rules
get ( $field ) Returns the original value of the field.
getActualFields ( ) Get list of fields which we are going to validate. In some cases it makes no sense to validate fields which are not appearing individually the form, therefore this method will look carefully at what you are validating.
getRules ( $field ) Call this to get list of parsed rules for specified field.
init ( ) {{{ Initialization method
is ( ) This method will go through all the rules you specify, expand and normalize them and assign into array indexed by field name.
normalizeRules ( $rules ) Provided with string containing rules, this will convert it into normal (array) form.
now ( ) Apply rules now.
on ( $hook, $object = null, $default_hook = false )
pullRule ( $alias = false ) Pulls next rule out of the rule stack (current_ruleset) May allow alias ($name).
pushRule ( ) Adds new rule into a rule-set, which will be executed next.
resolveRuleAlias ( $rule )
rule_caption ( $a ) }}}
rule_fail ( ) The only rule in Validator_Abstract. Will fail.
set ( $field, $value ) Changes the original value of the field (for normalization).
setSource ( $source ) If you are adding this Controller inside a Model, you don't need to set source. If you want controller to work with an array or some other object, use setSource().
stop ( )

Описание методов

applyRules() публичный Метод

This is the main body for rule processing.
public applyRules ( $field, $ruleset )

applyRulesets() публичный Метод

Go through the list of defined rules and call the corresponding filters and convertors.
public applyRulesets ( )

expandFieldDefinition() публичный Метод

In: "name,surname,foo" (Basic) In: "%boolean,-@address" (Advanced) Out: array('name','surname','foo')
public expandFieldDefinition ( $field_definition, &$normalized_rules )

fail() публичный Метод

{{{ Methods which are called by the rules
public fail ( )

get() публичный Метод

Returns the original value of the field.
public get ( $field )

getActualFields() публичный Метод

Get list of fields which we are going to validate. In some cases it makes no sense to validate fields which are not appearing individually the form, therefore this method will look carefully at what you are validating.
public getActualFields ( )

getRules() публичный Метод

Call this to get list of parsed rules for specified field.
public getRules ( $field )

init() публичный Метод

{{{ Initialization method
public init ( )

is() публичный Метод

You do not need to have your fields defined at this point, unless you specify wildcards. This method takes various arguments as described in documentation.
public is ( )

normalizeRules() публичный Метод

In: "int|required|alphanum|save" (Basic) In: "int!|a-z|" (Advanced) Out: array('int','required','alphanum','save')
public normalizeRules ( $rules )

now() публичный Метод

Apply rules now.
public now ( )

on() публичный Метод

public on ( $hook, $object = null, $default_hook = false )

pullRule() публичный Метод

Pulls next rule out of the rule stack (current_ruleset) May allow alias ($name).
public pullRule ( $alias = false )

pushRule() публичный Метод

You can specify single or multiple rules, this method accepts variable arguments. Rules must be normalized.
public pushRule ( )

resolveRuleAlias() публичный Метод

public resolveRuleAlias ( $rule )

rule_caption() публичный Метод

}}}
public rule_caption ( $a )

rule_fail() публичный Метод

The only rule in Validator_Abstract. Will fail.
public rule_fail ( )

set() публичный Метод

Changes the original value of the field (for normalization).
public set ( $field, $value )

setSource() публичный Метод

If you are adding this Controller inside a Model, you don't need to set source. If you want controller to work with an array or some other object, use setSource().
public setSource ( $source )

stop() публичный Метод

public stop ( )

Описание свойств

$acc публичное свойство

Next are system fields, do not access when in doubt.
public $acc

$active_field публичное свойство

Name of the field which is currently beind processed.
public $active_field

$alias публичное свойство

$alias['mandatory']='required'; $alias['must_have']='required';
public $alias

$bail_out публичное свойство

public $bail_out

$caption публичное свойство

public $caption

$cast публичное свойство

public $cast

$consumed публичное свойство

public $consumed

$current_ruleset публичное свойство

public $current_ruleset

$custom_error публичное свойство

public $custom_error

$custom_hook публичное свойство

Call this to set a different hook when rules are going to be applied. By default you have to call now() on() used by default for when validator is added, however if you call it manually (avoiding 3rd argument) it will override the default hook. This is done to avoid double-validation
public $custom_hook

$default_exception публичное свойство

public $default_exception

$has_hook публичное свойство

public $has_hook

$prefix публичное свойство

When transformivg value (such as len) - will contain a modifier to the error message.
public $prefix

$rules публичное свойство

Each ruleset is broken down by field and is stored in this array in a normal form. You can get rules for a particular field by calling $this->getRules(field);.
public $rules

$source публичное свойство

Validator can check either a model, array, form or any other object as long as it supports array_access. If you are using Model then you can use some additional functionality foreach selecting fields.
public $source