diff --git a/docs/usage.md b/docs/usage.md index 3e6b581..d96cda7 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -151,6 +151,25 @@ with `phone` (property of the source object). > Note: the source and the target property must be of the same type for this to work. +In order to set a default value for a property, you can use the `default` keyword: + +```yaml +# config/packages/neusta_converter.yaml +neusta_converter: + converter: + person.converter: + properties: + email: + source: ~ + default: unknown + phoneNumber: + source: phone + default: 0123456789 +``` + +Which will populate `email` with the value of the source property `email` or with the default value `unknown` if the +source property is `null`. + #### Mapping context If you just want to map a single property from the context to the target without transforming it in between, you don't