simpl-schema
Advanced tools
Changelog
1.2.1
Fix issues with Meteor Tracker reactivity sometimes not working when subschemas are involved.
Changelog
1.2.0
The performance of clean
, specifically of looping through the object to apply autoValues and defaultValues, has been greatly improved for large objects.
Changelog
1.1.2
Passing a definition with no type
to extend
now works as expected, as long as the existing definition already has a type
.
Changelog
1.1.1
Passing an array of schemas to new SimpleSchema()
or extend()
now throws an error rather than failing silently with strange results.
Changelog
1.1.0
autoConvert
cleaning now converts strings that are "true" or "false" to Boolean if the schema expects a Boolean.autoConvert
cleaning now converts numbers to Boolean if the schema expects a Boolean, with 0 being false
and all other numbers being true
.Changelog
1.0.0
BREAKING CHANGE: autoValue and defaultValue handling has been rewritten to fix all known issues. As part of this rewrite, the behavior has changed to address a point of common confusion.
Previously, when you cleaned an object to add autoValues, a defaultValue
would be added (and an autoValue
function would run) even if the parent object was not present. (It would be created.)
Now, an autoValue
/defaultValue
will run only if the object in which it appears exists. Usually this is what you want, but if you are relying on the previous behavior, you can achieve the same thing by making sure that all ancestor objects have a defaultValue: {}
.
For example, this:
{
profile: {
type: Object,
optional: true,
},
'profile.language': {
type: String,
defaultValue: 'en',
},
}
previously cleaned {}
to become { profile: { language: 'en' } }
but now would remain {}
. If you want cleaning to result in { profile: { language: 'en' } }
, add the profile
default value like:
{
profile: {
type: Object,
optional: true,
defaultValue: {},
},
'profile.language': {
type: String,
defaultValue: 'en',
},
}
If profile
were nested under another object, you'd have to add defaultValue: {}
to that object definition, too, and so on.
_constructorOptions key is missing "type"
error reappearing in some situationslength
Changelog
0.4.2
Changelog
0.4.0
getFormValidator()
, similar to validator()
but instead of throwing an error, it returns a Promise that resolves with the errors. This can be used as a Composable Form Specification validator.