Package su.onno.validation
Class AttributeValidator
java.lang.Object
su.onno.validation.AttributeValidator
Enforces the declarative
@Attribute constraints (required, string length, numeric
min/max, regex pattern, email) on an entity before write, collecting every failure into a
ValidationErrors keyed by field name. Works either against a typed aggregate (values
read reflectively) or against a submitted body map (the generic UI write path), so the same
rules apply however the write arrives.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvalidate(Object entity, List<AttributeDescriptor> attributes, ValidationErrors errors) Validate a typed aggregate, reading each attribute's value reflectively.voidvalidate(Map<String, Object> values, List<AttributeDescriptor> attributes, ValidationErrors errors) Validate a submitted body map keyed by attribute field name (the generic UI write path).voidvalidatePartial(Map<String, Object> values, List<AttributeDescriptor> attributes, ValidationErrors errors) Validate only the attributes a partial-update body actually submits.
-
Constructor Details
-
AttributeValidator
public AttributeValidator()
-
-
Method Details
-
validate
Validate a typed aggregate, reading each attribute's value reflectively. -
validate
public void validate(Map<String, Object> values, List<AttributeDescriptor> attributes, ValidationErrors errors) Validate a submitted body map keyed by attribute field name (the generic UI write path). -
validatePartial
public void validatePartial(Map<String, Object> values, List<AttributeDescriptor> attributes, ValidationErrors errors) Validate only the attributes a partial-update body actually submits. Updates touch just the keys present in the body, so an absent required attribute is "left unchanged", not "cleared" — flagging it would force clients to resend every required field on every write. A key that IS present with a null/blank value is still a violation (that write would clear the column).
-