We are going to deploy the new yiiframework.com website on March 23, 2018 from 8:00 to 12:00 UTC.
Website and Yii documentation will not be available in this time frame. Check the news for more details.

Yii 1.1: age-validator

Validates min/max age by birthdate


  1. Place EAgeValidator.php to <your_app>/protected/extensions/validators/age/ or any convenient directory
  2. Add path alias of extension to import section if you dont want to use full paths to EAgeValidator in your models.


#method of your model class, that you need to validate
public function rules()
    return array(
        # If you imported ext.validators.age.EAgeValidator or placed EAgeValidator.php
        # to directory, that is imported (for example, protected/components)
        array('your_birthdate_field_name1', 'EAgeValidator'),
        # With options and full path to extension   
        array('your_birthdate_field_name2', 'ext.validators.age.EAgeValidator',                    




Total 2 comments

#9484 report it
florin p at 2012/08/15 12:21pm
Client Validation


How can I integrate with client validation?

#6084 report it
dbk138 at 2011/12/10 07:12pm
Integration with Yii User


I am trying to add this to the Yii User module and I am having trouble making it work. I have tried adding it in the validators field on the profile field management and I have also tried adding it to the RegistrationForm model but neither way is working. Has anyone successfully added this to the Yii User module?

Leave a comment

Please to leave your comment.

Create extension