Closed andrenanninga closed 10 years ago
@FakeYou, I pushed a fix, but I can't do a new release until they fix some issues with atmosphere. If you want to try it out, you can point to the master github repo. I didn't try out the fix, but I'm cloning the schema argument now, so I assume that will prevent the modifications you mention.
Also, you could nest/combine the SimpleSchema instances instead of the objects, and that would work around your issue.
New release with this fix is available now.
Thanks I'll check it out.
I did notice you are using the underscore .clone method which only does a shallow clone so it still may prove a problem with nested schemas.
I didn't test, but I'm pretty sure nested/combined schemas are fine because it just grabs the internal schemas and merges them, and the internal schemas, in turn, will have been cloned already.
With the creation of a SimpleSchema the used object may be altered causing any creation of SimpleSchema's using the same object to contain a faulty ruleset.
for example:
now when logging the original
example
object you'll get this:I'm guessing this is used by SimpleSchema to handle Arrays as type.
The issue I encountered was when I later reusing this
example
object (and adding some new fields) that thesomething.$
was still present.With this new ruleset the SimpleSchema will no longer accept an Array of strings.
valid
will be false and the following errors will be present:Now I don't know if this is something known or something that should be fixed. It's something I came across and you should probably be vigilant for.