mirror of
https://codeberg.org/reflect/reflect-rules-plugin.git
synced 2025-09-14 00:43:42 +02:00
feat: add validate or return Reflect\Response method to Ruleset
This commit is contained in:
parent
9c837fd194
commit
d6accce069
1 changed files with 7 additions and 0 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
use \ReflectRules\Rules;
|
||||
|
||||
use \Reflect\Response;
|
||||
|
||||
require_once "Rules.php";
|
||||
|
||||
// Available superglobal scopes
|
||||
|
@ -169,4 +171,9 @@
|
|||
|
||||
return $this->is_valid;
|
||||
}
|
||||
|
||||
// Return Reflect\Response with errors and code 422 Unprocessable Content if validation failed
|
||||
public function validate_or_exit(): true|Response {
|
||||
return $this->is_valid() ? true : new Response($this->errors, 422);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue