question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

validate() always returns true with constructed custom objects

See original GitHub issue
var 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:closed
  • Created 8 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
matanlbcommented, Sep 24, 2015

+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.

0reactions
aldeedcommented, Aug 24, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found