Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculated fields #425

Open
georgolden opened this issue Jul 20, 2022 · 1 comment
Open

Calculated fields #425

georgolden opened this issue Jul 20, 2022 · 1 comment
Assignees

Comments

@georgolden
Copy link
Member

georgolden commented Jul 20, 2022

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
@alexpodelinskii
Copy link

I'll try to solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants