array
Adds description for Array field in DataCaster
instance.
This method is chainable.
Signature
array(originName, options = {})
options
is an object that can be omitted. To get more about options see Fields section
Example
import { DataCaster } from '@daminort/data-caster';
const dc = new DataCaster()
.int('id')
.string('name')
.array('places')
.array('weapons');
const result = dc.adapt(serverObject);
// before
{
id: 1,
name: 'John Snow',
places: ['Winterfell', 'Wall'],
weapons: undefined,
}
// after
{
id: 1,
name: 'John Snow',
places: ['Winterfell', 'Wall'],
weapons: [],
}