forked from jquense/yup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (42 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import mixed from './mixed';
import bool from './boolean';
import string from './string';
import number from './number';
import date from './date';
import object from './object';
import array from './array';
import Ref from './Reference';
import Lazy from './Lazy';
import ValidationError from './ValidationError';
import reach from './util/reach';
import isSchema from './util/isSchema';
import setLocale from './setLocale';
let boolean = bool;
let ref = (key, options) => new Ref(key, options);
let lazy = fn => new Lazy(fn);
function addMethod(schemaType, name, fn) {
if (!schemaType || !isSchema(schemaType.prototype))
throw new TypeError('You must provide a yup schema constructor function');
if (typeof name !== 'string')
throw new TypeError('A Method name must be provided');
if (typeof fn !== 'function')
throw new TypeError('Method function must be provided');
schemaType.prototype[name] = fn;
}
export {
mixed,
string,
number,
bool,
boolean,
date,
object,
array,
ref,
lazy,
reach,
isSchema,
addMethod,
setLocale,
ValidationError,
};