You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Best Practice Code Examples](#best-practice-code-examples)
93
+
-[Make a field conditionally required](#make-a-field-conditionally-required)
94
+
-[Validate one key against another](#validate-one-key-against-another)
95
+
-[Debug Mode](#debug-mode)
96
+
-[Extending the Schema Options](#extending-the-schema-options)
97
+
-[Converting a SimpleSchema to a JSONSchema](#converting-a-simpleschema-to-a-jsonschema)
98
+
-[Add On Packages](#add-on-packages)
99
+
-[Contributors](#contributors)
100
+
-[Sponsors](#sponsors)
101
+
-[License](#license)
102
+
-[Contributing](#contributing)
103
+
-[Thanks](#thanks)
103
104
104
105
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
105
106
@@ -856,11 +857,11 @@ There are three ways to validate an object against your schema:
856
857
1. With a unique named validation context, not throwing any Errors (schema.namedContext('someUniqueString').validate())
857
858
1. With the default validation context, not throwing any Errors. (schema.namedContext().validate())
858
859
859
-
A validation context provides reactive methods for validating and checking the validation status of a particular object.
860
+
A validation context provides methods for validating and checking the validation status of a particular object.
860
861
861
862
#### Named Validation Contexts
862
863
863
-
It's usually best to use a named validation context. That way, the context is automatically persisted by name, allowing you to easily rely on its reactive methods.
864
+
It's usually best to use a named validation context. That way, the context is automatically persisted by name, allowing you to easily rely on its methods.
864
865
865
866
Here is an example of obtaining a named validation context:
866
867
@@ -890,19 +891,19 @@ const schema = new SimpleSchema({
890
891
constmyValidationContext=schema.newContext();
891
892
```
892
893
893
-
An unnamed validation context is not persisted anywhere. It can be useful when you need to see if a document is valid but you don't need any of the reactive methods for that context, or if you are going to keep the context reference in memory yourself.
894
+
An unnamed validation context is not persisted anywhere. It can be useful when you need to see if a document is valid but you don't need any of the methods for that context, or if you are going to keep the context reference in memory yourself.
894
895
895
896
### Validating an Object
896
897
897
898
To validate an object against the schema in a validation context, call `validationContextInstance.validate(obj, options)`. This method returns `true` if the object is valid according to the schema or `false` if it is not. It also stores a list of invalid fields and corresponding error messages in the context object.
898
899
899
-
You can call `myContext.isValid()` to see if the object last passed into `validate()` was found to be valid. This is a reactive method that returns`true` or `false`.
900
+
You can call `myContext.isValid()` to see if the object last passed into `validate()` was found to be valid. Returns`true` or `false`.
900
901
901
902
For a list of options, see the [Validation Options](#validation-options) section.
902
903
903
904
### Validating Only Some Keys in an Object
904
905
905
-
You may have the need to (re)validate certain keys while leaving any errors for other keys unchanged. For example, if you have several errors on a form and you want to revalidate only the invalid field the user is currently typing in. For this situation, call `myContext.validate` with the `keys` option set to an array of keys that should be validated. This may cause all of the reactive methods to react.
906
+
You may have the need to (re)validate certain keys while leaving any errors for other keys unchanged. For example, if you have several errors on a form and you want to revalidate only the invalid field the user is currently typing in. For this situation, call `myContext.validate` with the `keys` option set to an array of keys that should be validated.
906
907
907
908
This method returns `true` only if all the specified schema keys and their descendent keys are valid according to the schema. Otherwise it returns `false`.
908
909
@@ -1043,7 +1044,7 @@ Whole-document validators have the following available on `this` context:
1043
1044
1044
1045
### Manually Adding a Validation Error
1045
1046
1046
-
If you want to reactively display an arbitrary validation error and it is not possible to use a custom validation function (perhaps you have to call a function `onSubmit` or wait for asynchronous results), you can add one or more errors to a validation context at any time by calling `myContext.addValidationErrors(errors)`, where `errors` is an array of error objects with the following format:
1047
+
If you want to display an arbitrary validation error and it is not possible to use a custom validation function (perhaps you have to call a function `onSubmit` or wait for asynchronous results), you can add one or more errors to a validation context at any time by calling `myContext.addValidationErrors(errors)`, where `errors` is an array of error objects with the following format:
0 commit comments