In this example you can see password and password_again attributes comparing using compare and compareAttribute.
Another example is validates if price is greater than or equal to 5000 using the compare and compareAttribute.
Yii2 Compare validation Rules
[ // validates "password" attribute equals to "password_again" ['password', 'compare'], // same as above but with explicitly specifying the attribute to compare with ['password', 'compare', 'compareAttribute' => 'password_again'], // validates if price is greater than or equal to 5000 ['price', 'compare', 'compareValue' => 5000, 'operator' => '>=', 'type' => 'number'], ]
Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
ReplyDeleteHire Yii Developers in India