Using phalcon 3.0.0 on windows wamp.
I want to validate the presence of the distance property in my model.
distance is also set as not NULL in mysql.
When I run $trip->save() I get an erorr message distance is required and my validator isn't called. Is there any way to make the validator run before other database checks?
class Trips extends Model {
public function validation() {
$validator = new Validation();
$validator->add('distance', new PresenceOf([
'model' => $this,
'message' => 'Fill in the distance',
]));
dump($this->distance);
dump($this->validate($validator));
exit();
return $this->validate($validator);
}
}