This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Phpr_Validation class

Defined in /phproad/modules/phpr/classes/phpr_validation.php, lines 23-399
Author LemonStand eCommerce Inc.
Validates model property values. Objects of this class are usually created with Db_ColumnDefinition::validation() method and validation is triggered within models, however they can be created and used separately.

Public methods

Method Description Defined By
add() adds a field validation rule set. Phpr_Validation
firstErrorField() returns name of the first field with error. Phpr_Validation
getError() returns an error message for a specified field. Phpr_Validation
isError() detects whether a field with the specified name has any errors assigned. Phpr_Validation
setError() sets a general or field-specific error message. Phpr_Validation
setFirstFocusName() sets a field name to focus for the first field having an error. Phpr_Validation
throwException() throws the Validation Exception in case if data is not valid. Phpr_Validation
validate() runs the validation rules. Phpr_Validation
__construct() creates a validation object. Phpr_Validation

Method details

add() method

public Phpr_ValidationRules add(string $column_name, string $label=NULL, boolean $focusable=true)
$column_name string specifies the field name.
$label string specifies the visual field label.
$focusable boolean determines whether the field is focusable.
{return} Phpr_ValidationRules returns the validation rule set object.
Adds a field validation rule set. Add the rule set object to add validation rules.

firstErrorField() method

public string firstErrorField()
{return} string returns the field name or null.
Returns name of the first field with error.

getError() method

public string getError(string $field, boolean $Html=true)
$field string specifies the field name.
$Html boolean indicates whether the message must be prepared to HTML output.
{return} string returns the error text or NULL.
Returns an error message for a specified field.

isError() method

public boolean isError(string $field)
$field string specifies the field name.
{return} boolean returns TRUE if the field has errors. Returns FALSE otherwise.
Detects whether a field with the specified name has any errors assigned.

setError() method

public Phpr_Validation setError(string $message, string $field=NULL, boolean $throw=false)
$message string specifies the error message text.
$field string specifies the field name. If this parameter is omitted, the general message will be set.
$throw boolean indicates whether the validation error should be thrown.
{return} Phpr_Validation returns the updated validation object.
Sets a general or field-specific error message.

setFirstFocusName() method

public void setFirstFocusName(string $name)
$name string specifies the field name. If the value has the '%s' specifier it will be replaced with the field name.
Sets a field name to focus for the first field having an error.

throwException() method

public void throwException()
Throws the Validation Exception in case if data is not valid.

validate() method

public boolean validate(mixed $data=NULL, string $deferred_session_key=NULL)
$data mixed specifies a data source - an array or object. If this parameter is omitted, the data from the POST array will be used.
$deferred_session_key string an edit session key for deferred bindings.
{return} boolean returns TRUE if the validation passed.
Runs the validation rules.

__construct() method

public void __construct(Phpr_Validatable $owner=NULL, string $form_id='FormElement')
$owner Phpr_Validatable specifies an optional owner model.
$form_id string specifies an optional HTML form identifier.
Creates a validation object.