Class OptionalRule

Description

The OptionalRule allows you to have a field where a rule is applied *only* when the value actually exists.

  • version: $Id: OptionalRule.class.php,v 1.7 2007/09/04 20:25:55 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

Located in /harmoni/core/utilities/FieldSetValidator/rules/OptionalRule.class.php (line 16)

ValidatorRuleInterface
   |
   --OptionalRule
Variable Summary
object ValidatorRule $_rule
Method Summary
void OptionalRule (object ValidatorRule $rule)
boolean check (mixed $val)
object ValidatorRule getRule (object ValidatorRule $rule)
string getRuleKey ()
Variables
object ValidatorRule $_rule (line 25)

the rule to be used for the values set

  • var: the rule
  • access: private
Methods
Constructor OptionalRule (line 34)

the constructur

  • access: public
void OptionalRule (object ValidatorRule $rule)
  • object ValidatorRule $rule: the rule to use for the value when set
check (line 46)

checks a given value to see if it's set (returns true if not), and then runs the rule on it.

  • return: true if the check succeeds, false if it (guess...) fails.
  • access: public
boolean check (mixed $val)
  • mixed $val: the value to check

Redefinition of:
ValidatorRuleInterface::check()
checks a given value against the rule contained within the class
getRule (line 72)

This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.

This method follows a modified Singleton pattern.

  • since: 3/28/05
  • static:
  • access: public
object ValidatorRule getRule (object ValidatorRule $rule)
  • object ValidatorRule $rule

Redefinition of:
ValidatorRuleInterface::getRule()
This is a static method to return an already-created instance of a validator rule. There are at most about a hundred unique rule objects in use durring any given execution cycle, but rule objects are instantiated hundreds of thousands of times.
getRuleKey (line 100)

Return a key that can be used to identify this Rule for caching purposes.

If this rule takes no arguments, the class name should be sufficient. otherwise, append the arguments.

This method should only be called by ValidatorRules.

  • since: 3/29/05
  • access: protected
string getRuleKey ()

Redefinition of:
ValidatorRuleInterface::getRuleKey()
Return a key that can be used to identify this Rule for caching purposes.

Inherited Methods

Inherited From ValidatorRuleInterface

ValidatorRuleInterface::check()
ValidatorRuleInterface::getRule()
ValidatorRuleInterface::getRuleKey()

Documentation generated on Wed, 19 Sep 2007 10:25:17 -0400 by phpDocumentor 1.3.0RC3