Skip to content

Add contract programming features to actions #10

@ioncreature

Description

@ioncreature

I want it to be declarative as fuck, so why don't I implement contract-programming features for actions?

It could be schema arguments validation or even by function
And I want the same (schema/function validation) to self-check what have action returned

So design by contract usually describes 4 steps for functions: expect/require for args, and returns/ensure for result

Action({

    fn(deps) {
        return () => {}; // the action itself
    }

    expect: [ // json schema for each argument here (what to do with spread args?)
        {
            type: 'string',
            pattern: '^[0-9]{1,19}$'
        },
        {
            type: 'array'
            minItems: 1,
            items: [{
                type: 'string',
            }]
        }
    ],

    require(x, y) {
        // do some validation
    },

    returns: {} // json schema here too
    ensure() {} // function here
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaJust an idea that could become feature request after some requirement investigation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions