Package com.jsgalactic.axiom.error
Record Class Violation
java.lang.Object
java.lang.Record
com.jsgalactic.axiom.error.Violation
- Record Components:
field- property path, for exampleitems[0].name, or empty for the whole valuecode- safe machine-readable code
One field-level problem reported to a client. Both values are sent in error responses, so they
are restricted to safe syntax: the field is a property path of at most 256 characters using ASCII
letters, digits,
_, -, . and [n] indexes, and the code follows
the AxiomException code syntax. Never build either from client input.
An empty field means the violation concerns the whole validated value (for example a rule that
compares two properties, or a null body) rather than one property. Problem responses
leave the field member out for such a violation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncode()Returns the value of thecoderecord component.final booleanIndicates whether some other object is "equal to" this one.field()Returns the value of thefieldrecord component.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Violation
Validates both values.- Parameters:
field- property pathcode- safe machine-readable code- Throws:
IllegalArgumentException- if either value has unsafe syntaxNullPointerException- if the field is null
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
field
Returns the value of thefieldrecord component.- Returns:
- the value of the
fieldrecord component
-
code
Returns the value of thecoderecord component.- Returns:
- the value of the
coderecord component
-