1

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)

armani
  • 303
  • 7
  • 18

1 Answers1

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