我想验证我的输入是 UUID 或“LAST_QUESTION”。我创建了一个自定义验证规则LastOrUUID,我想在其中使用 UUID 验证规则。我找不到任何方法来做到这一点,也许您知道实现此目的的正确方法是什么?我的上下文自定义规则:
class LastOrUUID implements Rule
{
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
if ($value === 'LAST_QUESTION' /* || this is uuid */) {
return true;
}
return false;
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
// TODO - add translation
return 'This should either be the last question or have a reference to next question!';
}
}
慕桂英3389331