Overtrue\Validation\Validator::validateExists PHP Method

validateExists() protected method

Validate the existence of an attribute value in a database table.
protected validateExists ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean
    protected function validateExists($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'exists');
        $table = $parameters[0];
        // The second parameter position holds the name of the column that should be
        // verified as existing. If this parameter is not specified we will guess
        // that the columns being "verified" shares the given attribute's name.
        $column = isset($parameters[1]) ? $parameters[1] : $attribute;
        $expected = is_array($value) ? count($value) : 1;
        return $this->getExistCount($table, $column, $value, $parameters) >= $expected;
    }
Validator