custom validation

i m not getting custom validation ,i read yii2 custom validation from documentation and from reference guide,but still confuse

how this code will work

like i have to field start_date and end_date

i want when user select date from calender then it will check user subscription period ,so i need show error when user select date befor or after of subscription date

user selecting start_date 2014-01-02 and end date 2014-05-02

if user selcting date in any form where i have datepicker it will check user subscription date if it is lying between then ok otherwise gives error.

my code

in model rules



public function valideStart_date($attributes,$params){

   here just check if select date is bigger then start_date then it is ok

otherwise gives error


same for end date

how to do this

How do you do which bit? It looks like you have the correct idea, what can’t you do?

Anyway, here is a link to how to use "custom" validation with an example: