Skip to content

Defining aliases in constructor #162

Closed
@icebob

Description

@icebob

Would be good to make that we can define aliases in the constructor options. The reason is that we can set it in ServiceBroker options of Moleculer.

Proposal:

const v = new Validator({
    aliases: {
        username: {
            type: 'string',
            min: 4,
            max: 30
        },
        password: {
            type: 'string',
            min: 6,
            max: 100,
            empty: false
        }
    }
});

And I will change the Moleculer side and we can use it as

//moleculer.config.js
module.exports = {
    nodeID: "node-100",
    validator: {
        type: "FastestValidator",
        options: {
            useNewCustomCheckerFunction: true,
            aliases: { ... },
            defaults: { ... },
            messages: { ... }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions