feat(form-builder): validForTargetType method on FormFieldBindingMergeStrategy
Per RFC-WS-6 §V1 + ARCH-BINDINGS §4.2. Implements the strategy x target-type validity matrix. Append is the only non-trivial case: valid only for COLLECTION targets. The AppendStrategyRequiresCollectionTarget publish-guard uses this method (D2 wiring confirms call sites; this commit provides the building block). Existing methods (nullWinnerBehaviour, isValidForScalarTargets) untouched. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -37,4 +37,31 @@ enum FormFieldBindingMergeStrategy: string
|
||||
{
|
||||
return $this !== self::Append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this strategy is structurally valid against the given target
|
||||
* type.
|
||||
*
|
||||
* Per RFC-WS-6 §V1 + ARCH-BINDINGS §4.2 (strategy x target-type validity matrix).
|
||||
*
|
||||
* | SCALAR | COLLECTION | RELATION |
|
||||
* Overwrite | valid | valid* | valid |
|
||||
* Append | INVALID| valid | INVALID |
|
||||
* Replace | valid | valid | valid |
|
||||
* FirstWriteWins | valid | valid | valid |
|
||||
*
|
||||
* * unusual but valid (overwrites entire collection)
|
||||
*
|
||||
* The PublishGuard AppendStrategyRequiresCollectionTarget uses this
|
||||
* method to validate at publish time. Append on scalars is rejected
|
||||
* because it requires a fingerprint mechanism for retry-idempotency
|
||||
* that would embed implementation detail in domain data.
|
||||
*/
|
||||
public function validForTargetType(BindingTargetType $type): bool
|
||||
{
|
||||
return match ($this) {
|
||||
self::Append => $type === BindingTargetType::COLLECTION,
|
||||
default => true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user