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

Why after validate(),object will be empty #106

Open
niezw opened this issue Dec 13, 2019 · 2 comments
Open

Why after validate(),object will be empty #106

niezw opened this issue Dec 13, 2019 · 2 comments

Comments

@niezw
Copy link

niezw commented Dec 13, 2019

const Schema = require('validate');
const _schema = new Schema({
    user: {
        type: Object,
        required: true,
    },
});

let _user = {
    name: "gavin",
    longName: "GavinNie",
};

console.log('_user 1', _user);
_schema.validate(_user);
console.log('_user 2', _user);

the console log:
GL: getConfig -> env local
_user 1 { name: 'gavin', longName: 'GavinNie' }
_user 2 {}

@niezw
Copy link
Author

niezw commented Dec 13, 2019

Same situation when _user is const, so the _user attribute is been deleted

@Kupstas
Copy link

Kupstas commented Feb 11, 2020

I think it because the strict mode is enable by default and all field not from the _schema has been erased.

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

2 participants