Object initialization, setting all the default values.
OptionalnewData: anythe data to load, optional
Optionaloptions: anycustom options to apply; they will depend on the child resource
Usually, there is no need to implement the constructor; implicitly, it will call the load of the child resource
and therefore loading all the resources with default values.
If needed, this is the suggested implementation:
super();
this.load(x);
// ...
Field default value.
Explanation of the field.
OptionalenumThe list of the possible values (strings); available only with type ENUM.
OptionalenumThe translations of the enum keys; available only with type ENUM. Not obligatory: the fallback is always the enum key.
OptionalfieldId of the field.
The icon to show to identify the field.
OptionalmaxMax value the field can assume; available only with type NUMBER.
OptionalminMin value the field can assume; available only with type NUMBER.
Name of the field.
If true, an obligatory check will be performed; ignored with type BOOLEAN.
OptionalteamThe id of the team owning the field. Optional.
The type of the custom field.
Return an attribute in a cleaned standard that force-cast the element.
the origin attribute, to cast
the cast function, e.g. Boolean, Number, String, x => new CustomClass(x), etc.
OptionaldefaultVal: anyif set, the fallback value instead of null
cleaned attribute
Return an array in a cleaned standard that force-cast each element, keeping only the valid ones.
the origin array, to cast and check
the cast function, e.g. x => String(x) or x => new CustomClass(x)
OptionaldefaultVal: anyif set, the fallback value instead of null
cleaned array
Set a default value for the field, based on its type.
the determinated default value, based on the type
Get the enum in the form of array of Suggestions.
Optionallanguage: stringOptionallanguages: LanguagesGet the label to show for the enum, based on the translations available; if none, returns the key.
Optionallanguage: stringOptionallanguages: LanguagesShortcut to Utils.isEmpty to check the emptiness of a field.
Optionaltype: isEmptyFieldTypesLoad the attributes from an already existing resource.
Optionallanguages: LanguagesLoad a value based on the field configuration.
the value to load
Load the attributes from an already existing resource and then force some attributes to assume safeData values. The function is usually used in the back-end to mix together db data with new data, without the risk of changing ids and other attributes which are managed in appositely curated scenario.
the data to load
the attributes to force to specific values
Optionallanguages: LanguagesValide the object's attributes, performing all the checkings.
Optionallanguages: Languageserrors if empty, the checkings are successfully passed.
Typical implementation:
const e = super.validate();
if(this.iE(this.attr)) e.push(`attr`);
// ...
return e;
Validate a field value, based on the field configuration.
the value to check
return false in case of error
Metadata of a custom field.