Yii 1.1: cascaded-validator

Applies any validator to an attributes, but only if another attribute matches certain preconditions
1 follower

This extension is a simple Validator. It can be used to validate a model attribute with any other built in or custom validator. It is only evaluated if another attribute fulfills certain preconditions (checked via any built in or custom validator).

Resources

Documentation

Requirements

  • Yii 1.1.2 or above (might work with early version, too)

Installation

  • Extract the release file under protected/validators
  • Add 'application.validators.*' to the 'import' array in the global config

Usage

See the following code example:

public function rules()
{
    return array(
        array('userEmail', 'CascadedValidator', 'parentRule' => array('receiveNewsletter', 'match', 'pattern' => '/yes, please/'), 'childRule' => array('email'), 'negateParentCheck' => false),
    );
}

Change Log

June 25, 2010

  • Initial release.

Be the first person to leave a comment

Please to leave your comment.

Create extension