Class RuleSet

Description

a RuleSet allows a user to define a number of keys each with associated rules and errors

  • version: $Id: RuleSet.class.php,v 1.8 2007/09/05 19:55:22 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

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


	
			
Variable Summary
array $_rules
Method Summary
void RuleSet ()
void addRule (string $key, ref $rule, [optional $message = null], [mixed $type = ''])
int count ()
array getKeys ()
boolean validate (string $key, mixed $val, [optional $throwErrors = true])
Variables
array $_rules (line 30)

an associative array of keys and associated rules

the format of the array is this: [key1]=>array( $rule1, $error1), array( $rule2, $error2), ... [key2]=>...

  • var: the associative array of rules
  • access: private
Methods
Constructor RuleSet (line 38)

the constructor

  • access: public
void RuleSet ()
addRule (line 50)

adds a new $rule to $key, which if fails when validated throws $error

  • access: public
void addRule (string $key, ref $rule, [optional $message = null], [mixed $type = ''])
  • string $key: the key to associate the rule with
  • ref $rule: object ValidatorRule $rule the ValidatorRule object to be added
  • optional $message: string $message the error to throw if the validation fails
count (line 111)

returns the number of keys with rules

  • return: the number of keys
  • access: public
int count ()
getKeys (line 100)

returns an array of keys

  • return: an array of keys that are set
  • access: public
array getKeys ()
validate (line 70)

validates $val against the rules defined for $key. if validation fails the associated error is thrown

  • return: if the validation succeeded or failed
  • access: public
boolean validate (string $key, mixed $val, [optional $throwErrors = true])
  • string $key: the key to look at for rules
  • mixed $val: the value to check against the rules
  • optional $throwErrors: boolean $throwErrors Should we throw the specified errors if validation fails or just return true/false. Default = TRUE.

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