Need to validate a field in database for uniqueness before saving in model, I can do :
public function validation()
{
$validator = new Validation();
$validator->add('unit', new Uniqueness([
"message" => "The unit is already in use"
]));
return $this->validate($validator);
}
But I need to do two make two more tests:
- I need to first check UNIT in other table-- if it exists there or not ,
- Units with value = 0 has to be ignored as there are multiple units with 0 value.
So how can properly utilize phalcon Validation for my need.