Class ActiveRecord_Errors

Description

Errors collection class for ActiveRecord. Every ActiveRecord instance has a corresponding ActiveRecord_Errors instance, even if no errors exist for the object.

Located in /activerecord/lib/ActiveRecord/Errors.php (line 17)


	
			
Variable Summary
 mixed $base
 mixed $errors
Method Summary
 ActiveRecord_Errors __construct (ActiveRecord_Base $base)
 void add (string $attr, [string $msg = false])
 void add_on_boundary_breaking (mixed $attr, int $lowerBound, int $upperBound, [string $msgShort = false], [string $msgLong = false])
 void add_on_empty (mixed $attr, [string $msg = false])
 void add_to_base (string $msg)
 void clear ()
 array full_messages ()
 bool is_empty ()
 void is_invalid (string $attr)
 array on (string $attr)
 array on_base ()
 int size ()
Variables
mixed $base (line 21)

The object we belong to

  • access: protected
mixed $errors (line 26)

Error messages keyed by attribute

  • access: protected
Methods
Constructor __construct (line 33)

Constructor

  • access: public
ActiveRecord_Errors __construct (ActiveRecord_Base $base)
add (line 56)

Add an error message to the named attribute. Multiple error message may be associated with a single attribute. If no message is provided, the message "is invalid" is used.

  • access: public
void add (string $attr, [string $msg = false])
  • string $attr: The attribute name
  • string $msg: The message fragment to use
add_on_boundary_breaking (line 95)

Conditionally adds an error message to the list of supplied

attributes when the string length of the attribute values are outside a given range. If no error messages are provided, the messages "is too short (min $lowerBound)" / "is too long (max $upperBound)" are used.

  • access: public
void add_on_boundary_breaking (mixed $attr, int $lowerBound, int $upperBound, [string $msgShort = false], [string $msgLong = false])
  • mixed $attr: The attibute name or array of attribute names
  • int $lowerBound: The minimum required characters
  • int $upperBound: The maximum required characters
  • string $msgShort: The message fragment to use for short attributes
  • string $msgLong: The message fragment to use for long attributes
add_on_empty (line 71)

Conditionally adds an error message to the list of supplied attributes when the attribute values are empty (determined by the PHP function empty()). If no error message is provided, the message "is required" is used.

  • access: public
void add_on_empty (mixed $attr, [string $msg = false])
  • mixed $attr: The attibute name or array of attribute names
  • string $msg: The message fragment to use
add_to_base (line 44)

Add an error message that pertains to the base object as opposed to a particular attribute on the object.

  • access: public
void add_to_base (string $msg)
  • string $msg: The error message.
clear (line 173)

Clear all errors from the collection.

  • access: public
void clear ()
full_messages (line 148)

Return the collection of all full error messages.

  • access: public
array full_messages ()
is_empty (line 166)

Returns true if the list of errors is empty

  • access: public
bool is_empty ()
is_invalid (line 116)

Returns true if the named attribute has errors

  • access: public
void is_invalid (string $attr)
  • string $attr: The attribute name to test
on (line 129)

Return the list of errors associated with the named attribute.

Note, this function always returns an array whether zero, one, or more errors exists.

  • access: public
array on (string $attr)
  • string $attr: The attribute to return errors for
on_base (line 139)

Returns any errors associated with the base class as opposed to a sepecific attribute.

  • access: public
array on_base ()
size (line 182)

Return the total number of errors in the collection (same as count(full_messages())).

  • access: public
int size ()

Documentation generated on Wed, 25 Apr 2012 09:46:42 -0700 by phpDocumentor 1.4.3