Added support for calculate and convert for data fields.
@examples
calculate (its all up to you)
fields: [{
name: 'id',
type: 'Number'
}, {
name: 'name',
defaultValue: 'Defaults To Name',
/**
* @config data the record
* @config field the field definition
* @config rawData the data as they come initially
*/
calculate: (data, field, rawData) => {
// foo will not exist in data, but in this example
// foo is delivered with the initial data
if (rawData) return rawData.foo;
data.name ??= field.defaultValue;
return 'I am ' + data.name;
}
}]convert (will run the standard afterwards, like minLength and maxLength)
fields: [{
name: 'id',
type: 'Number'
}, {
name: 'name',
defaultValue: 'Defaults To Name',
convert: value => 'I am ' + value
}]
Added support for
calculateandconvertfor data fields.@examples calculate (its all up to you)
fields: [{ name: 'id', type: 'Number' }, { name: 'name', defaultValue: 'Defaults To Name', /** * @config data the record * @config field the field definition * @config rawData the data as they come initially */ calculate: (data, field, rawData) => { // foo will not exist in data, but in this example // foo is delivered with the initial data if (rawData) return rawData.foo; data.name ??= field.defaultValue; return 'I am ' + data.name; } }]convert (will run the standard afterwards, like minLength and maxLength)
fields: [{ name: 'id', type: 'Number' }, { name: 'name', defaultValue: 'Defaults To Name', convert: value => 'I am ' + value }]