refactor(form-builder): strict validator on save; strip rules.unique fallback
This commit is contained in:
@@ -53,9 +53,7 @@ final class FormFieldValidationRuleService
|
||||
*/
|
||||
public function replaceRules(FormField|FormFieldLibrary $owner, array $specs): void
|
||||
{
|
||||
foreach ($specs as $spec) {
|
||||
$this->assertSpecValid($spec);
|
||||
}
|
||||
$this->assertSpecsValid($specs);
|
||||
|
||||
$ownerType = $this->ownerTypeFor($owner);
|
||||
|
||||
@@ -182,6 +180,21 @@ final class FormFieldValidationRuleService
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Public wrapper around `assertSpecValid` — iterates a caller-supplied
|
||||
* list and throws the first `UnknownValidationRuleTypeException`.
|
||||
* Used by FormRequests (WS-5b commit 3 strict validator on save) to
|
||||
* reject bad specs at the HTTP boundary before any write lands.
|
||||
*
|
||||
* @param list<array<string, mixed>> $specs
|
||||
*/
|
||||
public function assertSpecsValid(array $specs): void
|
||||
{
|
||||
foreach ($specs as $spec) {
|
||||
$this->assertSpecValid($spec);
|
||||
}
|
||||
}
|
||||
|
||||
private function ownerTypeFor(FormField|FormFieldLibrary $owner): string
|
||||
{
|
||||
return $owner instanceof FormField ? 'form_field' : 'form_field_library';
|
||||
|
||||
Reference in New Issue
Block a user