jonathangeiger / kohana-jelly

See the link below for the most up-to-date code
https://github.com/creatoro/jelly
MIT License
146 stars 34 forks source link

save() should trigger validation() #2

Closed dewos closed 14 years ago

dewos commented 14 years ago

See title :)

banks commented 14 years ago

I agree actually.

jonathangeiger commented 14 years ago

How should this be handled? Should an exception be thrown? Should save() return a boolean? I'll definitely add this but I want to hear some opinions on how the API should work.

dewos commented 14 years ago

Save just call check(). Validation Class throws the exceptions (if any).

jonathangeiger commented 14 years ago

The validation class doesn't throw any exceptions on failure.

dewos commented 14 years ago
    if ( ! $data->check())
    {
        throw new Validate_Exception($data);
    }
banks commented 14 years ago

Fixed in branch: commit.

Jon, can you merge this to master and close when you are happy with it. (Note I have not tested this exhaustively but I'm fairly sure it will work as expected.)