Javatpoint Logo
Javatpoint Logo

Ad hoc Validation

To validate values that are not bound to any model, we need to use ad hoc validation. Or if you want to validate values without models then use ad hoc validation.

To perform one type of validation, you may call yii\validators\validator() method of the desired validator.

Not all the valdiators support this type of validation.

For example, we are calling yii\validators\DateValidator()

But to perform multiple validations, against several values you can use yii\base\DynamicModel which defines both attributes and rules.

For example, here we are calling DynamicModel to validate date and email.

On the browser, pass the URL

http://localhost/ad_hoc/frontend/web/index.php?r=site/ad-hoc-validation

YII Ad hoc validation 1

Look at the above output, both date and email have been validated at the same time.





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA