Class AttributeValidator

java.lang.Object
su.onno.validation.AttributeValidator

public final class AttributeValidator extends Object
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 Details

    • AttributeValidator

      public AttributeValidator()
  • Method Details

    • validate

      public void validate(Object entity, List<AttributeDescriptor> attributes, ValidationErrors errors)
      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).