validate() always returns true with constructed custom objects
See original GitHub issuevar schema = new SimpleSchema({ name: { type: String }});
var context = schema.newContext();
context.validate({}); // correctly returns false
context.validate(new Object()); // correctly returns false
function User() {}
context.validate(new User()); // returns true, should return false
context.validate(new (function() {})); // returns true, should return false
Issue Analytics
- State:
- Created 8 years ago
- Comments:6
Top Results From Across the Web
Page.Validate() with a custom validator. err.IsValid returns true ...
confirms what you have said about the order. I have tried it by moving Page.Validate() to the line before I create the validator....
Read more >Model validation in ASP.NET Core MVC | Microsoft Learn
A non-nullable field is always valid, and the [Required] ... Here's an example of an action method that returns a custom error message:....
Read more >Spring Validation Example - Spring MVC Form Validator
We can create our custom validator implementations in two ways - the ... The validation method is isValid and it returns true if...
Read more >The best way to implement custom validators - Angular inDepth
The validator itself is just a function that accepts an AbstractControl and returns an Object containing the validation error or null if everything...
Read more >Client-side form validation - Learn web development | MDN
Always remember to help your users correct the data they provide. ... Built-in form validation uses HTML form validation features, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 This is a really weird behavior. I don’t understand why this constraint is needed, but even if it is it makes more since to throw an error detailing this then always returning true.
Thanks for your patience. SimpleSchema 2.0.0-rc.1 is now released and includes changes that resolve this issue.
There are a number of breaking changes when updating to 2.0, so be sure to check out the change log. If you use aldeed:collection2, you will need to use 2.10.0 or higher of that package in order to use SimpleSchema 2.0. If you use autoform, it is not yet updated to work with SimpleSchema 2.0, but hopefully soon.
SimpleSchema is now an isomorphic NPM package, so you can check out the updated readme and file issues over at the other repo. The Meteor wrapper package will exist for now but eventually I will probably deprecate support for it.
This is still a beta/RC and I do expect people will find issues, so use with caution. Production use is not yet recommended. That said, there are more and better unit tests than ever before, and the codebase should be much easier for others to read through and debug quickly.