Table of Contents generated with DocToc
- 1.7.3 and higher
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.9
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
- 0.0.4
Release notes for versions 1.7.3 and higher can be found at https://github.com/aldeed/simpl-schema/releases
Update message-box
dependency again to fix IE11 support
Update message-box
dependency to fix IE11 support
If an array item (field ending with .$
) has optional: true
, this now allows it to have null
items without any validation error being thrown. Previously adding optional: true
to an array item had no effect.
- Adds
SimpleSchema.regEx.idOfLength
for variable length IDs - Removes
deep-extend
dependency to fix undefinedBuffer
errors
Omit test files from the published package
- Removes all
lodash
packages - Replaces
extend
package withdeep-extend
, which is smaller and is the same package used by themessage-box
dependency - Improve the performance of handling fields with
blackbox: true
(thanks @cwouam) - Add a
this
context for all rule functions (see README) (thanks @Neobii) - Add a
this
context for all whole-doc validator functions (see README) (thanks @bhunjadi)
Fix issues with autoValues not being available in other autoValues
Update dependencies to fix vulnerabilities
Update Babel config in an attempt to fully support IE11s
- Update dependencies
- Adjust the way Babel builds so that you don't need to do
.default
when importing in a non-Babel Node project.
- Fix #294 - Now auto-converting values during cleaning does not convert if the value type is any of the types in a
oneOf
type
- Add
$setOnInsert
to modifiers for defaultValues only whenisUpsert
is set totrue
in clean options or in extended autoValue context. It used to be ignored but newer MongoDB versions throw an error. Might fix #304 - Fix #307 - Test for empty object when creating schema (thanks @coagmano)
- autoValue functions sort preserves fields order on the same depth (thanks @bhunjadi)
getAllowedValues
now returnsnull
whenallowedValues
isn't set (thanks @MohammedEssehemy)- Update Mocha and other dependencies
- Readme updates (thanks @ozzywalsh)
Update to latest mongo-object package dependency
Include README.md and LICENSE in the published package
- Fix issues with
$pull
modifier being incorrectly cleaned in some cases where some properties havedefaultValue
(thanks @vparpoil) - Other behind-the-scenes refactoring
allowedValues
may now be aSet
instance (thanks @kevinkassimo)- Updated
EmailWithTLD
regular expression with one that is not susceptible to catastrophic backtracking attacks (thanks @davisjam)
- Forgetting to define the parent key of any key in a schema will now throw an error
- use Array.forEach to remove empty objects fixes #244 (#246)
The SimpleSchema constructor or .extend()
will now throw an error if you define an Array field but forget to define the corresponding array item field.
Fixed an issue where defaultValues would be incorrectly added to $setOnInsert
when your modifier contained $unset
for deeply nested fields.
- Fixed an issue where the defaultValue
$setOnInsert
added to a modifier containing$addToSet
would target an incorrect object path. - When cleaning, it no longer tries to convert the type of
null
. - Any value returned from autoValue/defaultValue is now cloned to prevent accidental mutation.
- Added
this.key
in the function context when executing schema definition properties that are functions. This can help you determine what the array index is for keys that are within arrays. - Added a
clone()
function on SimpleSchema instances.
Add this.key
and this.closestSubschemaFieldName
to autoValue
context to help with tricky situations when subschemas are used.
Fix an issue introduced by 1.2.1, where it was possible for a SimpleSchema instance passed to extend
to be mutated.
Fix issues with Meteor Tracker reactivity sometimes not working when subschemas are involved.
The performance of clean
, specifically of looping through the object to apply autoValues and defaultValues, has been greatly improved for large objects.
Passing a definition with no type
to extend
now works as expected, as long as the existing definition already has a type
.
Passing an array of schemas to new SimpleSchema()
or extend()
now throws an error rather than failing silently with strange results.
- The
autoConvert
cleaning now converts strings that are "true" or "false" to Boolean if the schema expects a Boolean. - The
autoConvert
cleaning now converts numbers to Boolean if the schema expects a Boolean, with 0 beingfalse
and all other numbers beingtrue
.
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.
- Fix regression that resulted in
_constructorOptions key is missing "type"
error reappearing in some situations - Fix errors when validating an object that has a property named
length
- Remove underscore dependency in favor of seperated lodash modules
- Fix to properly add defaultValues in objects that are being $pushed in an update modifier
- Fix removeNullsFromArrays to remove only nulls
Fix cleaning an object with a length
property
- Added
getFormValidator()
, similar tovalidator()
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. - Throw a better error when keys that conflict with Object prototype keys are used (Thanks @xavierpriour)
- Fix the incorrect "Found both autoValue and defaultValue options" warning (Thanks @SachaG)
Bump dependencies to fix messages
issues
- When calling
pick
oromit
, themessageBox
and all originalSimpleSchema
constructor options are now properly kept. (Thanks @plumpudding) - Fixed #80 (Thanks @jasonphillips)
getQuickTypeForKey
may now return additional strings "object" or "objectArray"- Fix erroneous "Found both autoValue and defaultValue" warning (Thanks @SachaG)
- Fix passing of clean options when extending
- Other fixes to extending logic
- Added human-friendly
message
to each validation error in thedetails
array on a thrown ClientError (thanks @unknown4unnamed) - Fixed isInteger error on IE11 (thanks @lmachens)
- Switched to duck typing for
SimpleSchema
instanceof checks to fix failures due to multiple instances of the package (thanks @dpankros) - Fixed multiple calls to
messages
for different schemas from affecting the other schemas (thanks @Josh-ES)
- Add missing deep-extend dependency
- Fixed Meteor Tracker reactivity
- It is no longer considered a validation error when a key within $unset is not defined in the schema.
- Added
ssInstance.getQuickTypeForKey(key)
- Added
ssInstance.getObjectSchema(key)
- Improved error for missing
type
property - Use _.contains instead of Array.includes to fix some compatibility issues (thanks @DerekTBrown)
- Various documentation and test fixes
- Added
ssInstance.getAllowedValuesForKey(key)
- Removed the
babel-polyfill
dependency. It may not cause problems, but to be safe you'll want to be sure that your app depends on and importsbabel-polyfill
or some other ES2015 polyfill package. this.validationContext
is now available in all custom validator functions (thanks @yanickrochon)- You can now call
SimpleSchema.setDefaultMessages(messages)
, passing in the same object you would pass to theMessageBox
constructor, if you want to override the default messages for all schemas. This is in addition to being able to setschema.messageBox
to your own customMessageBox
instance for a single schema, which you could already do. (thanks @clayne11) - Labels with certain characters like single quotes will now show up correctly in validation error messages. (thanks @clayne11)
extend
is now chainable- Requiredness validation now works for required fields that are in subschemas
- Fixed some issues with autoValues not being correctly added when they were deeply nested under several levels of arrays and objects.