Specifies which property in the raw data should be assigned to the model's property. By default, Paris looks for a property of the same name as the property in the model. i.e:
If an entity has the following property definition:
@EntityField()
name:string;
Then when creating the model, if the raw data contains a name
property with value 'Anna', the resulting model will have a name
property with value 'Anna'.
A value to assign to the property if the raw data is null
or undefined.
An ID for the field. By default, the ID is the property's name.
Optional name to assign to the field. May be used for reflection, debugging, etc.
Parses the raw data before it's used by Paris to create the property's value
Sometimes the value in the raw data is not formatted as we'd like, or more information might be needed to create the desired value. A field's parse
configuration is available for changing the raw data before it's passed to Paris.
Important: parse
should return a new RAW data, not a Paris model.
A condition that has to be satisfied in order to assign value to the property.
If a field's required
is set to true
, it means that the property must have a value for the whole model to be created.
If required
is true
and the property has a value of null
or undefined
, then the model itself will be null.
A method used to serialize the model field's data back into raw data, to be used when saving the model to backend.
serialize
may also be set to false
, in which case the field won't be included in the serialized model.
Generated using TypeDoc
arrayOf
is required when the property's type is an array of a sub-model type. It's required because the ES6 Reflect-metadata module that Paris uses to infer the types of properties doesn't support generics.@EntityField({ arrayOf: Address }) addresses: Array<Address>