DataValidationCompiler
class DataValidationCompiler
Constants
| protected PRESENCE_RULES |
|
| protected INFERRED_RULE_TYPES |
The attribute type of each inferred rule, which a declared attribute of that type replaces. |
Methods
Create a data validation compiler.
Compile validation for one filled root data collection.
Compile one data node into the root rule graph.
Compile nested rules for one data iterable.
Compile one data iterable from its current structure path.
Compile dynamic items at one wildcard path when their complete output matches.
Build the rules for one property: inferred presence and type rules, then declared attributes.
Get the fresh validation attributes declared on a property.
Infer fixed presence and type rules for one property.
Run the configured rule inferrers over one property's inferred and attribute rules.
Resolve the configured rule inferrers for one compilation.
Apply class-owned rule replacements in PHP property-name space.
Collapse concrete translations onto an existing authoritative wildcard rule.
Apply class-owned messages and attribute labels in PHP property-name space.
Invoke one array-returning validation lifecycle method.
Resolve a field reference's property names to input names.
Translate a class rule key to its observed wire paths.
Recursively translate class-rule segments through Data metadata.
Translate the rest of a key that reaches a finished value.
Append rule segments that no longer describe Data properties.
Append wildcard identity markers after every rule replacement is complete.
Determine if a rule list contains a distinct rule.
Merge rule lists without duplicating identical string rules.
Determine if a rule list explicitly controls field presence.
Get the keyword of a string or structured validation rule.
Determine if item rules can differ across one collection.
Get the inferred type rule for one property value.
Get the wire key selected during Fill or its canonical fallback.
Get the data object or data collection type that receives a property's value on the current node.
Record an exact field or opaque subtree excluded from rule compilation.
Determine if a skipped property can contain nested input.
Determine if a validated property has no recursive schema.
Determine if a named object type has no Data-owned child schema.
Details
at line 82
__construct(DataClassRepository $dataClasses, Container $container, RuleDenormalizer $ruleDenormalizer, RuleNormalizer $ruleNormalizer, DataConfig $config)
Create a data validation compiler.
at line 94
CompiledValidation
compile(ConstructionState $state)
Compile validation for one filled data graph.
at line 132
CompiledValidation
compileCollection(ConstructionState $state, string $dataClass)
Compile validation for one filled root data collection.
at line 175
protected array
preservedPaths(ValidationAccumulator $accumulator)
Get the paths restored after validation.
A constructor input is restored only when no compiled rule applies to it or to anything beneath it; otherwise the validated result owns it.
at line 219
protected void
compileNode(string $class, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields, DataClass|null $rootDataClass, bool $observed = true)
Compile one data node into the root rule graph.
at line 463
protected void
compileDataIterable(DataProperty $property, string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields, DataClass|null $rootDataClass)
Compile nested rules for one data iterable.
at line 502
protected void
compileDataIterableValues(string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $compileUnknownFields, DataClass|null $rootDataClass)
Compile one data iterable from its current structure path.
at line 635
protected ValidationAccumulator|null
compileUniformDynamicIterable(string $dataClass, array $values, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, array $lifecycleDeclarations, bool $compileUnknownFields, DataClass|null $rootDataClass)
Compile dynamic items at one wildcard path when their complete output matches.
at line 688
protected array
propertyRules(DataProperty $property, ValidationPath $nodePath, ValidationContext|null $context, ValidationPath $propertyPath, bool $hasValue, mixed $value, ConstructionState $state, string|Enum|null $typeRule, bool $receivesDataCollection, bool $inferredRequired, Closure $resolveField)
Build the rules for one property: inferred presence and type rules, then declared attributes.
at line 815
protected array
declaredRuleAttributes(DataProperty $property)
Get the fresh validation attributes declared on a property.
A Rule attribute's rules become typed attributes where possible, so they replace inferred rules of their type.
at line 838
protected array
inferRules(DataProperty $property, string|object|null $typeRule, bool $hasPresenceRule, bool $receivesDataCollection, bool $hasValue)
Infer fixed presence and type rules for one property.
at line 885
protected PropertyRules
applyRuleInferrers(DataProperty $property, array $attributes, array $inferredRules, ValidationContext $context, ConstructionState $state)
Run the configured rule inferrers over one property's inferred and attribute rules.
Declared attributes follow the inferred rules and replace inferred rules of the same type.
at line 917
protected array
resolveRuleInferrers()
Resolve the configured rule inferrers for one compilation.
They are resolved per compilation, so scoped inferrers follow the current coroutine.
at line 934
protected void
applyClassRules(DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationContext|null $context, ValidationPath $structuralPath, ValidationAccumulator $accumulator, bool $observed, Closure $resolveField)
Apply class-owned rule replacements in PHP property-name space.
at line 1025
protected array
collapseTranslatedRulePaths(array $paths, ValidationAccumulator $accumulator)
Collapse concrete translations onto an existing authoritative wildcard rule.
at line 1053
protected void
applyClassMessagesAndAttributes(DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, ValidationAccumulator $accumulator, array $lifecycleDeclarations, bool $observed)
Apply class-owned messages and attribute labels in PHP property-name space.
at line 1137
protected array
callArrayLifecycleMethod(DataClass $dataClass, string $method, array $parameters = [])
Invoke one array-returning validation lifecycle method.
at line 1164
protected string
resolveFieldReference(FieldReference $reference, ValidationPath $path, DataClass $dataClass, DataClass|null $rootDataClass, bool $mapPropertyNames)
Resolve a field reference's property names to input names.
Unlike rule keys, references are not filtered, since a condition may read input that has no rules.
at line 1223
protected array
translateRulePaths(string $key, DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, bool $observed, bool $allowsRuleSuffix = false)
Translate a class rule key to its observed wire paths.
at line 1250
protected array
translateRuleSegments(array $segments, int $offset, DataClass $dataClass, ConstructionState $state, ValidationPath $path, ValidationPath $structuralPath, bool $observed, bool $allowsRuleSuffix = false)
Recursively translate class-rule segments through Data metadata.
at line 1469
protected array
finishedValuePaths(ValidationPath $path, ValidationPath $structuralPath, array $segments, int $offset, bool $allowsRuleSuffix)
Translate the rest of a key that reaches a finished value.
A finished value is not validated internally, so only a key ending at the value applies, or a message key ending with one rule for it.
at line 1493
protected ValidationPath
appendUnmappedSegments(ValidationPath $path, array $segments, int $offset)
Append rule segments that no longer describe Data properties.
at line 1510
protected void
appendStructuralMarkers(ValidationAccumulator $accumulator, array $payload)
Append wildcard identity markers after every rule replacement is complete.
at line 1588
protected bool
hasDistinctRule(array $rules)
Determine if a rule list contains a distinct rule.
at line 1610
protected array
mergeRules(array $rules, array $additionalRules)
Merge rule lists without duplicating identical string rules.
at line 1628
protected bool
hasPresenceRule(array $rules)
Determine if a rule list explicitly controls field presence.
at line 1646
protected string|null
ruleKeyword(mixed $rule)
Get the keyword of a string or structured validation rule.
at line 1660
protected bool
usesDynamicRules(string $dataClass, ConstructionState $state)
Determine if item rules can differ across one collection.
at line 1675
protected string|Enum|null
primitiveRule(DataProperty $property)
Get one unambiguous type validation rule.
at line 1695
protected string|Enum|null
typeRuleFor(NamedType $type)
Get the type rule for one declared named type.
at line 1717
protected string|Enum|null
inferredTypeRule(DataProperty $property, bool $hasValue, mixed $value, NamedType|null $dataType)
Get the inferred type rule for one property value.
A union value uses the rule of the declared type that holds it, so numeric size rules keep their numeric meaning. Other values use the declaration's rule.
at line 1744
protected string|int
wireKey(DataProperty $property, ConstructionState $state, bool $observed)
Get the wire key selected during Fill or its canonical fallback.
at line 1764
protected NamedType|null
receivingDataType(DataProperty $property, ConstructionState $state, bool $hasValue, mixed $value)
Get the data object or data collection type that receives a property's value on the current node.
A union value uses the type Fill selected from the raw value, because Fill replaced a data value with its normalized input. Without a value, the declaration's one data type applies.
at line 1782
protected void
recordAuxiliaryPath(DataProperty $property, ValidationPath $path, ValidationAccumulator $accumulator)
Record an exact field or opaque subtree excluded from rule compilation.
at line 1797
protected bool
canContainDescendants(DataProperty $property)
Determine if a skipped property can contain nested input.
at line 1818
protected bool
hasUnstructuredDescendants(DataProperty $property)
Determine if a validated property has no recursive schema.
at line 1836
protected bool
isUnstructuredObject(NamedType $type)
Determine if a named object type has no Data-owned child schema.