Package org.hawaiiframework.web.resource
Class ValidationErrorResourceAssembler
- java.lang.Object
-
- org.hawaiiframework.converter.AbstractModelConverter<ValidationError,ValidationErrorResource>
-
- org.hawaiiframework.web.resource.ValidationErrorResourceAssembler
-
- All Implemented Interfaces:
ModelConverter<ValidationError,ValidationErrorResource>
public class ValidationErrorResourceAssembler extends AbstractModelConverter<ValidationError,ValidationErrorResource>
- Since:
- 2.0.0
- Author:
- Marcel Overdijk
-
-
Constructor Summary
Constructors Constructor Description ValidationErrorResourceAssembler(ObjectMapper objectMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
convert(ValidationError validationError, ValidationErrorResource resource)
Converts the given source object into the target object.protected String
convertProperty(String propertyName)
Converts the given property name (field name or error code) using the application definedPropertyNamingStrategy
for consistent output in responses.-
Methods inherited from class org.hawaiiframework.converter.AbstractModelConverter
convert, convert, instantiateTargetObject
-
-
-
-
Constructor Detail
-
ValidationErrorResourceAssembler
public ValidationErrorResourceAssembler(ObjectMapper objectMapper)
-
-
Method Detail
-
convert
public void convert(ValidationError validationError, ValidationErrorResource resource)
Description copied from interface:ModelConverter
Converts the given source object into the target object.- Parameters:
validationError
- the source objectresource
- the target object
-
convertProperty
protected String convertProperty(String propertyName)
Converts the given property name (field name or error code) using the application definedPropertyNamingStrategy
for consistent output in responses. The naming strategy is defined inapplication.yml
via thespring.jackson.property-naming-strategy
property.For example, if the
PropertyNamingStrategy.SnakeCaseStrategy
is defined, the following field names and error codes will be translated as following:- description -> description
- price -> price
- discountPrice -> discount_price
- Required -> required
- InvalidLength -> invalid_length
-
-