HTML_QuickForm2
[ class tree: HTML_QuickForm2 ] [ index: HTML_QuickForm2 ] [ all elements ]

Class: HTML_QuickForm2_Rule

Source Location: /HTML_QuickForm2-0.2.0/QuickForm2/Rule.php

Class Overview


Abstract base class for HTML_QuickForm2 rules


Author(s):

Version:

  • Release: 0.2.0

Variables

Methods


Child classes:

HTML_QuickForm2_Rule_Nonempty
Rule checking that the field is not empty
HTML_QuickForm2_Rule_Compare
Rule comparing the value of the field with some other value
HTML_QuickForm2_Rule_MaxFileSize
Rule checking that uploaded file size does not exceed the given limit
HTML_QuickForm2_Rule_Regex
Validates values using regular expressions
HTML_QuickForm2_Rule_Length
Rule checking the value's length
HTML_QuickForm2_Rule_Callback
Rule checking the value via a callback function (method)
HTML_QuickForm2_Rule_MimeType
Rule checking that uploaded file is of the correct MIME type
HTML_QuickForm2_Rule_Empty
Rule checking that the field is empty

Inherited Variables

Inherited Methods


Class Details

[line 58]
Abstract base class for HTML_QuickForm2 rules

This class provides methods that allow chaining several rules together. Its validate() method executes the whole rule chain starting from this rule.



[ Top ]


Class Variables

$chainedRules = array(array())

[line 87]

Rules chained to this via "and" and "or" operators

The contents can be described as "disjunctive normal form", where an outer array represents a disjunction of conjunctive clauses represented by inner arrays.

  • Access: protected

Type:   array


[ Top ]

$message =

[line 70]

An error message to display if validation fails
  • Access: protected

Type:   string


[ Top ]

$options =

[line 76]

Additional data for the rule
  • Access: protected

Type:   mixed


[ Top ]

$owner =

[line 64]

An element whose value will be validated by this rule
  • Access: protected



[ Top ]

$registeredType =  null

[line 97]

Type that was provided to Factory when creating this Rule instance

Used to get the common configuration data for the Rules of that type from Factory.

  • Access: protected

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 111]

HTML_QuickForm2_Rule __construct( HTML_QuickForm2_Node $owner, [string $message = ''], [mixed $options = null], [string $registeredType = null])

Class constructor
  • Access: public

Parameters:

HTML_QuickForm2_Node   $owner   —  Element to validate
string   $message   —  Error message to display if validation fails
mixed   $options   —  Additional data for the rule
string   $registeredType   —  Type that was provided to Factory when creating this Rule instance, shouldn't be set if instantiating the Rule object manually.

[ Top ]

and_   [line 187]

HTML_QuickForm2_Rule and_( HTML_QuickForm2_Rule $next)

Adds a rule to the chain with an "and" operator

Evaluation is short-circuited, next rule will not be evaluated if the previous one returns false. The method is named this way because "and" is a reserved word in PHP.

  • Return: first rule in the chain (i.e. $this)
  • Throws: HTML_QuickForm2_InvalidArgumentException when trying to add a "required" rule to the chain
  • Access: public

Parameters:

HTML_QuickForm2_Rule   $next   — 

[ Top ]

checkValue   [line 261]

boolean checkValue( mixed $value)

Validates the element's value

Note that the error message will be set for an element if such message exists in the rule and that method returns false

  • Return: Whether the value is valid according to the rule
  • Abstract:
  • Access: protected

Overridden in child classes as:

HTML_QuickForm2_Rule_Nonempty::checkValue()
HTML_QuickForm2_Rule_Compare::checkValue()
Validates the element's value
HTML_QuickForm2_Rule_MaxFileSize::checkValue()
Validates the element's value
HTML_QuickForm2_Rule_Regex::checkValue()
Validates the element's value
HTML_QuickForm2_Rule_Length::checkValue()
Validates the element's value
HTML_QuickForm2_Rule_Callback::checkValue()
Validates the element's value
HTML_QuickForm2_Rule_MimeType::checkValue()
Validates the element's value
HTML_QuickForm2_Rule_Empty::checkValue()

Parameters:

mixed   $value   —  Form element's value

[ Top ]

getMessage   [line 159]

string getMessage( )

Returns the error message output by the rule
  • Return: Error message
  • Access: public

[ Top ]

getOptions   [line 137]

mixed getOptions( )

Returns the rule's configuration data
  • Access: public

[ Top ]

or_   [line 210]

HTML_QuickForm2_Rule or_( HTML_QuickForm2_Rule $next)

Adds a rule to the chain with an "or" operator

Evaluation is short-circuited, next rule will not be evaluated if the previous one returns true. The method is named this way because "or" is a reserved word in PHP.

  • Return: first rule in the chain (i.e. $this)
  • Throws: HTML_QuickForm2_InvalidArgumentException when trying to add a "required" rule to the chain
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Rule_Required::or_()
Disallows adding a rule to the chain with an "or" operator

Parameters:

HTML_QuickForm2_Rule   $next   — 

[ Top ]

setMessage   [line 148]

HTML_QuickForm2_Rule setMessage( string $message)

Sets the error message output by the rule
  • Access: public

Parameters:

string   $message   —  Error message to display if validation fails

[ Top ]

setOptions   [line 126]

HTML_QuickForm2_Rule setOptions( mixed $options)

Sets additional configuration data for the rule
  • Access: public

Parameters:

mixed   $options   —  Rule configuration data (rule-dependent)

[ Top ]

setOwner   [line 170]

void setOwner( HTML_QuickForm2_Node $owner)

Sets the element that will be validated by this rule
  • Todo: We should consider removing the rule from previous owner
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Rule_MaxFileSize::setOwner()
Sets the element that will be validated by this rule
HTML_QuickForm2_Rule_MimeType::setOwner()
Sets the element that will be validated by this rule

Parameters:

HTML_QuickForm2_Node   $owner   —  Element to validate

[ Top ]

validate   [line 229]

boolean validate( )

Performs validation

The whole rule chain is executed. Note that the side effect of this method is setting the error message on element if validation fails

  • Return: Whether the element is valid
  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:10:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.