Skip to content

Commit

Permalink
Publish 2.0.0-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aldeed committed Aug 23, 2016
1 parent d833117 commit 4f271e7
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 32 deletions.
180 changes: 178 additions & 2 deletions .npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 37 additions & 29 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,43 @@ A simple, reactive schema validation smart package for Meteor.

### 2.0.0

- You must now `import { SimpleSchema } from 'meteor/aldeed:simple-schema';` wherever you use `SimpleSchema`
- `SimpleSchemaValidationContext` is now `SimpleSchema.ValidationContext`
- If you prefer keys to be optional by default, you can pass `requiredByDefault: false` as a SimpleSchema constructor option and then use `required: true` for each key that should be required.
- Implicit keys are no longer added for you. You must define every key. The one exception is array items when using shorthand (see next change)
- You can now use shorthand for keys when your schema is extra super duper simple. See "Shorthand Syntax" in the README.
- `validationContext.resetValidation()` is renamed to `validationContext.reset()`
- `validationContext.removeInvalidKeys()` has been removed since it is effectively the same as `validationContext.reset()`.
- Removed `validationContext.getErrorObject()` since the `ValidationError` thrown by `simpleSchema.validate()` fills this need.
- A `SimpleSchema` can no longer be used with the `check` package `check` function. Instead, use `simpleSchema.validate()`, which throws a more helpful ValidationError and satisfies `audit-argument-checks`.
- `validationContext.validateOne()` is removed and instead you can pass a `keys` array as an option to `validationContext.validate()`
- `invalidKeys()` is changed to `validationErrors()`, `_invalidKeys` is changed to `_validationErrors`, and `addInvalidKeys` is changed to `addValidationErrors`
- The error objects returned by `validationErrors()` and attached to thrown `ValidationError` objects now have additional properties that help describe the particular error.
- `decimal` is no longer a valid schema option. Instead, decimal/float is the default, and you can set the `type` to `SimpleSchema.Integer` to specify that you want only integers.
- In custom validation functions, you can now do `this.addValidationErrors(errors)`, where errors is an array of error objects. This allows you to add errors for keys other than the one you are validating.
- The `SimpleSchema.ErrorTypes` object now contains constants for all of the built-in error type strings.
- If you returned the error strings "expectedString", "expectedNumber", "expectedBoolean", "expectedArray", "expectedObject", or "expectedConstructor" prior to 2.0, you should now return SimpleSchema.ErrorTypes.EXPECTED_TYPE instead.
- Error message changes:
- SimpleSchema now uses `MessageBox` to manage validation error messages. Among other things, this means that placeholder text should now use handlebars syntax, `{{label}}` instead of `[label]`
- In the message context (for placeholders), `[type]` is now `{{dataType}}` and `[key]` is now `{{name}}`, though `key` still works for now.
- `SimpleSchema.messages` is removed. You can call `MessageBox.defaults` directly instead.
- `SimpleSchema.prototype.messages` is removed. You can call `simpleSchemaInstance.messageBox.messages()` instead, and you must pass in the messages in the format required by that package.
- `SimpleSchema._globalMessages` and `SimpleSchema._depsGlobalMessages` internal properties are removed.
- If you have custom regEx messages, you now need to do this by overriding the `regEx` messages function.
- SimpleSchema constructor no longer accepts an array to merge schemas. Instead, pass a single schema and then use `schema.extend(otherSchema)` to extend it.
- When validating, objects with a custom prototype were previously treated as blackbox objects. Now they are validated by default, so you must add `blackbox: true` to your schema if you want to keep the old behavior. The exceptions are Date objects and TypedArray objects, which are always treated as blackbox.
- You can now specify multiple combinations of type and certain other validation criteria for a single field. This is done using `SimpleSchema.oneOf`. Refer to the documentation for details.
- Cleaning an object no longer mutates it. However, you can pass `mutate: true` option to improve performance if you don't mind the object being mutated.
- You can now add custom whole-document validators, either globally or for one schema. See `SimpleSchema.addDocValidator` and `simpleSchemaInstance#addDocValidator`.
- If you pass an array of objects to `simpleSchemaInstance#validate`, all objects will be validated, and an error will be thrown for the first invalid object.
- SimpleSchema is now primarily an NPM package located here: https://github.com/aldeed/node-simple-schema The Meteor package will continue to be published and will make Meteor-specific adjustments as necessary, but you should attempt to migrate to using the NPM package directly as soon as you can.
- You should now `import { SimpleSchema } from 'meteor/aldeed:simple-schema'` (Meteor package) or `import SimpleSchema from 'simpl-schema'` (NPM package) in every file where you use `SimpleSchema`.
- Renamed:
- `SimpleSchemaValidationContext` -> `SimpleSchema.ValidationContext`
- `validationContext.resetValidation()` -> `validationContext.reset()`
- `validationContext.invalidKeys()` -> `validationContext.validationErrors()`
- `validationContext.addInvalidKeys()` -> `validationContext.addValidationErrors()`
- Removed:
- `validationContext.removeInvalidKeys()`: It was effectively the same as `validationContext.reset()`.
- `validationContext.getErrorObject()`: The `ValidationError` thrown by `simpleSchema.validate()` fills this need.
- `validationContext.validateOne()`: Instead you can pass a `keys` array as an option to `validationContext.validate()`.
- Other Breaking Changes:
- `decimal` is no longer a valid schema option. Instead, decimal/float is the default, and you can set the `type` to `SimpleSchema.Integer` to specify that you want only integers.
- Error message changes:
- SimpleSchema now uses `MessageBox` to manage validation error messages. Among other things, this means that placeholder text should now use handlebars syntax, `{{label}}` instead of `[label]`
- In the message context (for placeholders), `[type]` is now `{{dataType}}` and `[key]` is now `{{name}}`, though `key` still works for now.
- `SimpleSchema.messages` is removed. You can call `MessageBox.defaults` directly instead.
- `SimpleSchema.prototype.messages` is removed. You can call `simpleSchemaInstance.messageBox.messages()` instead, and you must pass in the messages in the format required by that package.
- `SimpleSchema._globalMessages` and `SimpleSchema._depsGlobalMessages` internal properties are removed.
- If you have custom regEx messages, you now need to do this by overriding the `regEx` messages function.
- SimpleSchema constructor no longer accepts an array to merge schemas. Instead, pass a single schema and then use `schema.extend(otherSchema)` to extend it.
- When validating, objects with a custom prototype were previously treated as blackbox objects. Now they are validated by default, so you must add `blackbox: true` to your schema if you want to keep the old behavior. The exceptions are Date objects and TypedArray objects, which are always treated as blackbox.
- The internal storage of your schema object has changed, so calling `simpleSchemaInstance.schema()` will now return an object that looks different. One of the differences is that subschemas are not merged into it. To get an object with subschemas merged, you can call `simpleSchemaInstance.mergedSchema()`. However, there are still differences due to how groups/`oneOf` is handled internally.
- Implicit keys are no longer added for you. You must define every key.
- A `SimpleSchema` can no longer be used with the `check` package `check` function. Instead, use `simpleSchema.validate()`, which throws a more helpful ValidationError and satisfies `audit-argument-checks`.
- If you have custom validation that returns the error strings "expectedString", "expectedNumber", "expectedBoolean", "expectedArray", "expectedObject", or "expectedConstructor", you should now return `{ type: SimpleSchema.ErrorTypes.EXPECTED_TYPE, dataType: 'String' }` instead, where `dataType` is "Boolean", "String", "Object", "Array", "Integer", or "Number".
- Cleaning an object no longer mutates it. However, you can pass `mutate: true` option to improve performance if you don't mind the object being mutated.
- Reactivity of labels and error messages in client code is no longer automatic. When creating your `SimpleSchema` instance, pass `{ tracker: Tracker }` in the options to enable Tracker reactivity.
- New Features
- If you prefer keys to be optional by default, you can pass `requiredByDefault: false` as a SimpleSchema constructor option and then use `required: true` for each key that should be required.
- You can now use shorthand for keys when your schema is extra super duper simple. See https://github.com/aldeed/node-simple-schema#shorthand-definitions
- The error objects returned by `validationErrors()` and attached to thrown `ValidationError` objects now have additional properties that help describe the particular error.
- In custom validation functions, you can now do `this.addValidationErrors(errors)`, where errors is an array of error objects. This allows you to add errors for keys other than the one you are validating.
- The `SimpleSchema.ErrorTypes` object now contains constants for all of the built-in error type strings.
- You can now specify multiple combinations of type and certain other validation criteria for a single field. This is done using `SimpleSchema.oneOf`. Refer to https://github.com/aldeed/node-simple-schema#multiple-definitions-for-one-key
- You can now add custom whole-document validators, either globally or for one schema. See `SimpleSchema.addDocValidator` and `simpleSchemaInstance#addDocValidator`.
- If you pass an array of objects to `simpleSchemaInstance#validate`, all objects will be validated, and an error will be thrown for the first invalid object.

### 1.4.0

Expand Down
5 changes: 4 additions & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Package.describe({
});

Npm.depends({
'simpl-schema': '0.0.1'
'simpl-schema': '0.0.3'
});

Package.onUse(function(api) {
Expand All @@ -19,6 +19,9 @@ Package.onUse(function(api) {
]);

api.mainModule('main.js');

// Need this for backwards compatibility for now
api.export('SimpleSchema');
});

// Package.onTest(function(api) {
Expand Down

0 comments on commit 4f271e7

Please sign in to comment.