* Create a new rule instance. * * @return void */ publicfunction__construct($values) { $this->values = $values; }
* Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ publicfunctionpasses($attribute, $value) { if (! $value) { returntrue; }
$values = explode(',', $value);
foreach ($values as $value) { if (! in_array($value, $this->values, true)) { returnfalse; } }
returntrue; }
* Get the validation error message. * * @return string */ publicfunctionmessage() { return'The :attribute must be the following types: '.implode(', ', $this->values).'.'; } }
近期评论