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

Defining aliases in constructor #162

Closed
icebob opened this issue Jun 16, 2020 · 2 comments
Closed

Defining aliases in constructor #162

icebob opened this issue Jun 16, 2020 · 2 comments

Comments

@icebob
Copy link
Owner

icebob commented Jun 16, 2020

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: { ... }
        }
    }
}
@erfanium
Copy link
Collaborator

erfanium commented Jun 16, 2020

What about v.add(...)? adding a new rule. it's not covered in Moleculer (Likely)

@icebob
Copy link
Owner Author

icebob commented Jun 16, 2020

Yeah, good idea, we can also add it as customs: {...}

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