metaschema
metaschema copied to clipboard
Calculated fields
Is your feature request related to a problem? Please describe.
const schema = new Schema('File', {
Entity: {},
size: 'number',
ratio: { method: (file) => file.size / 10, returns: 'number' },
});
const obj = { size: 100 };
const obj1 = schema.calculate(obj);
// Schema.check(obj);
// Assign new calculated fields with given object
For memory only shorthand:
const schema = new Schema('File', {
size: 'number',
ratio: (file) => file.size / 10,
});
const obj = { size: 100 };
const obj1 = schema.calculate(obj);
// Schema.check(obj);
// Assign new calculated fields with given object
I'll try to solve this issue