I'm going to get field data that exists in database or be in a range. is it possible to check input validation, that concurrent (exists in field database) OR (in:0,NULL)
Asked
Active
Viewed 2,693 times
1
-
1create a custom validation rule based on this http://stackoverflow.com/questions/26121417/laravel-validation-exists-with-additional-column-condition-custom-validation/26122468#26122468 – Jarek Tkaczyk Oct 01 '14 at 08:32
-
Thank you Jarek Tkaczyk. – armani Oct 01 '14 at 10:48
1 Answers
5
We should determine custom validator like this:
public function validateCustomExists($attribute, $value, $parameters)
{
if ($value == 0)
return true;
else
return $this->validateExists($attribute, $value, $parameters);
}
and in model validation:
$this->rules = array(
'field_id' => 'custom_exists:tableName,fieldName',
);

armani
- 303
- 7
- 18