The mapper class constructor takes an optional options object MapperConfig
that allows to change a few ways the mapper behaves. If no object is passed, the default values will be used as found bellow.
Option | Type | Default | Description |
---|---|---|---|
allowUninitializedFields | bool | true | If disabled, the mapper will fail if one of the class properties that does not have a default value was not present in the data array. |
classCacheKeySource | string | fqcn | Configures what hashing data is used to create the cache file for the classes. fqcn uses the fully-qualified class name, md5 uses an md5 hash of the file content and modified uses the last modified date from the class file. |
classMapperDirectory | string | /tmp/mappers | This is the location the mapper will create cached mapper functions for objects. The default location is a mappers function in the operating system temporary folder. |
debug | bool | false | Enabling debug will clear all cached mapper functions after mapping has completed. |
enumTryFrom | bool | false | Enabling this will use the ::tryFrom() method instead of ::from() to parse strings to enums. |
nullObjectFromEmptyArray | bool | false | If enabled, an empty array will be mapped to null value if the object type is nullable. |
strictNullMapping | bool | true | If enabled, the mapper will throw an error when a null value is passed for a property that was not typed as nullable. |