Communicating with database in validation

Hi

I need to check to see if a submitted date range overlaps any existing date ranges in the database

I know how to do the check but i’m wondering where to do it and if there’s a best practice for it

It seems a bit odd to communicate with the database in a validator somehow

Is this something that should be done in the controller maybe?

I was thinking about just calling a finder in the ‘Add’ action of the controller and returning true/false depending on whether it returns any rows or not

Anybody done this?

Would really appreciate a few pointers folks

The best way to implement application rules
http://book.cakephp.org/3.0/en/orm/validation.html#applying-application-rules

Okay thanks I’ll try that

I didn’t really understand what they were for but it looks like it should do the trick

Cheers