Skip to main content
Transformers take complex values and transform them into simple types. For example, a Carbon object could be transformed to 16-05-1994T00:00:00+00.

Transformer Interface

Implement the Transformer interface:

Parameters

  • property - DataProperty object representing the property being transformed (read more)
  • value - The value to transform (never null)
  • context - TransformationContext containing:
    • transformValues - Whether values should be transformed
    • mapPropertyNames - Whether property names should be mapped
    • wrapExecutionType - The execution type for wrapping values
    • transformers - Collection of available transformers

Return Value

Return the transformed value.

Example Transformer

Use in your data class:

Combining Transformers and Casts

Create a class that both transforms and casts:
Use with the WithCastAndTransformer attribute: