@@ -88,6 +88,7 @@ json separate from validating it, via the `cast` method.
88
88
89
89
You define and create schema objects. Schema objects are immutable, so each call of a method returns a _ new_ schema object.
90
90
91
+ __ try it out using tonicdev! https://tonicdev.com/570c52590a85f71200eb09ba/yup __
91
92
``` js
92
93
var yup = require (' yup' )
93
94
@@ -142,7 +143,7 @@ yup.addMethod
142
143
yup .ValidationError
143
144
```
144
145
145
- #### ` .reach(schema: Schema, path: string, value: ?object, context: ?object): Schema `
146
+ #### ` yup .reach(schema: Schema, path: string, value: ?object, context: ?object): Schema`
146
147
147
148
For nested schema's ` yup.reach ` will retrieve a nested schema based on the provided path.
148
149
@@ -164,7 +165,7 @@ reach(schema, 'nested.arr[1].num')
164
165
reach (schema, ' nested["arr"][1].num' )
165
166
```
166
167
167
- #### ` .addMethod(schemaType: Schema, name: string, method: ()=> Schema): void `
168
+ #### ` yup .addMethod(schemaType: Schema, name: string, method: ()=> Schema): void`
168
169
169
170
Adds a new method to the core schema types. A friendlier convenience method for ` schemaType.prototype[name] = method ` .
170
171
@@ -182,17 +183,7 @@ Adds a new method to the core schema types. A friendlier convenience method for
182
183
})
183
184
```
184
185
185
- #### ` ValidationError(errors: string | Array<string>, value: any, path: string) `
186
-
187
- Thrown on failed validations, with the following properties
188
- - ` name ` : "ValidationError"
189
- - ` path ` : a string, indicating where there error was thrown. ` path ` is empty at the root level.
190
- - ` errors ` : array of error messages
191
- - ` inner ` : in the case of aggregate errors, inner is an array of ` ValidationErrors ` throw earlier in the
192
- validation chain. When the ` abortEarly ` option is ` false ` this is where you can inspect each error thrown,
193
- alternatively ` errors ` will have all the of the messages from each inner error.
194
-
195
- #### ` ref(path: string, options: { contextPrefix: string }): Ref `
186
+ #### ` yup.ref(path: string, options: { contextPrefix: string }): Ref `
196
187
197
188
Creates a reference to another sibling or sibling descendant field. Ref's are resolved
198
189
at _ run time_ and supported where specified. Ref's are evaluated in in the proper order so that
@@ -211,6 +202,15 @@ inst.cast({ foo: { bar: 'boom' } }, { context: { x: 5 } })
211
202
// { baz: 'boom', x: 5, { foo: { bar: 'boom' } }, }
212
203
```
213
204
205
+ #### ` ValidationError(errors: string | Array<string>, value: any, path: string) `
206
+
207
+ Thrown on failed validations, with the following properties
208
+ - ` name ` : "ValidationError"
209
+ - ` path ` : a string, indicating where there error was thrown. ` path ` is empty at the root level.
210
+ - ` errors ` : array of error messages
211
+ - ` inner ` : in the case of aggregate errors, inner is an array of ` ValidationErrors ` throw earlier in the
212
+ validation chain. When the ` abortEarly ` option is ` false ` this is where you can inspect each error thrown,
213
+ alternatively ` errors ` will have all the of the messages from each inner error.
214
214
215
215
### mixed
216
216
@@ -701,7 +701,7 @@ Value must be a negative number.
701
701
Transformation that coerces the value into an integer via truncation
702
702
` value | 0 ` . If ` strict ()` is set it will only validate that the value is an integer.
703
703
704
- #### ` round (type: ' floor' | ' ceil' | ' round' = ' round' ): Schema`
704
+ #### ` number . round (type: ' floor' | ' ceil' | ' round' = ' round' ): Schema`
705
705
706
706
Rounds the value by the specified method (defaults to 'round').
707
707
@@ -758,7 +758,7 @@ array().of(number())
758
758
array (number ())
759
759
` ` `
760
760
761
- ### ` array .of (type: Schema): Schema`
761
+ #### ` array .of (type: Schema): Schema`
762
762
763
763
Specify the schema of array elements. ` of ()` is optional and when omitted the array schema will
764
764
not validate its contents.
@@ -776,7 +776,7 @@ Set an minimum length limit for the array. The `${min}` interpolation can be use
776
776
777
777
Set an maximum length limit for the array. The ` ${max}` interpolation can be used in the ` message` argument.
778
778
779
- ### ` array .ensure (): Schema`
779
+ #### ` array .ensure (): Schema`
780
780
781
781
Ensures that the value is an array, by setting the default to ` []` and transforming ` null ` and ` undefined `
782
782
values to an empty array as well. Any non-empty, non-array value will be wrapped in an array.
@@ -787,7 +787,7 @@ array().ensure().cast(1) // -> [1]
787
787
array ().ensure ().cast ([1 ]) // -> [1]
788
788
` ` `
789
789
790
- ### ` array .compact (rejector : (value ) => boolean): Schema`
790
+ #### ` array .compact (rejector : (value ) => boolean): Schema`
791
791
792
792
Removes falsey values from the array. Providing a rejecter function lets you specify the rejection criteria yourself.
793
793
0 commit comments