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

Validation for nested properties #7

Open
leandono opened this issue Dec 18, 2014 · 0 comments
Open

Validation for nested properties #7

leandono opened this issue Dec 18, 2014 · 0 comments

Comments

@leandono
Copy link

Hi! I'm trying to do some validations in a model definition with nested properties, for example:

Model definition

/**
 * Global modules
 */
var modella = require('modella');
var validators = require('modella-validators');

/**
 * Contact attributes and validations
 */
var Contact = modella('Contact');

Contact
    .attr('personal')
    .attr('personal.name', { required: true })
    .attr('personal.email', { required: true, format: 'email' })
    .use(validators);

Controller

var contact = New Contact({
    personal: {
        name: 'Leandro',
        email: '[email protected]'
    }
});

console.log(contact.isValid());
console.log(contact.toJSON());

Result

false
{ personal: { name: 'Leandro', email: '[email protected]' } }

Does the module support validations for nested objects or this is a bug?

Thanks!

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

No branches or pull requests

1 participant