vlucas/spot2 — pull request #41 by brownrl (2014-10-22 13:41:14+00:00)
Title: [ADD] added two functions that I think will make validation easier?

Never did github pull request before, I feel uber ( uber cool or uber stupid yet to be determined ). For the project I am on I added two functions to my entities.

the regexErrors() goes through any field with [ 'regex' => '/sample/' ]
and does a preg match. I think it could be handy for a field that holds for example and email address.

'user_email' => [ blah bla blah, 'regex' => '/^..*\@..*\...*$/'];

The check unique i added because it seemed like unique fields where not being fully checked on save or insert. Maybe I am totally wrong there.

at any rate if it is new, and the unique'd field value is not already in the DB go ahead.
if old and the unique'd field value is open for use go ahead.

Both of the functions I call on a beforeSave event.

Maybe you can bring them in, make them better, just thought I try to help.

Regards,
Rob