metaschema icon indicating copy to clipboard operation
metaschema copied to clipboard

Calculated fields

Open georgolden opened this issue 2 years ago • 1 comments

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

georgolden avatar Jul 20 '22 16:07 georgolden

I'll try to solve this issue

alexpodelinskii avatar Jul 27 '22 22:07 alexpodelinskii