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

shape() validation crash on undefined #740

Open
xuntaka opened this issue Jan 21, 2022 · 2 comments
Open

shape() validation crash on undefined #740

xuntaka opened this issue Jan 21, 2022 · 2 comments

Comments

@xuntaka
Copy link

xuntaka commented Jan 21, 2022

Describe the bug

Nope.object().shape({a: Nope.string()}).validate(undefined);
TypeError: Cannot read property 'validate' of undefined

Nope.object().shape({a: Nope.string()}).validate();
TypeError: Cannot read property 'validate' of undefined

Expected behavior
It should return undefined like other items validation eg

Nope.array().of(Nope.string()).validate();
undefined
@xuntaka
Copy link
Author

xuntaka commented Jan 21, 2022

And it's look like shape validation not work generally

 let sss = Nope.object().shape({ a: Nope.string().required() })
undefined
 sss.validate({ b: 123 })
{ a: 'This field is required' }
 sss.validate({ a: 123 })
undefined
 sss.validate({ a: [123] })
undefined

@xuntaka
Copy link
Author

xuntaka commented Jan 21, 2022

Ouhhh

 Nope.array().of(Nope.string()).validate(1);
TypeError: entry.some is not a function

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