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
파일 보기 프로젝트 열기: atk4/atk4 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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