UNPKG

1.1 kBJavaScriptView Raw
1import mixed from './mixed';
2import bool from './boolean';
3import string from './string';
4import number from './number';
5import date from './date';
6import object from './object';
7import array from './array';
8import Ref from './Reference';
9import Lazy from './Lazy';
10import ValidationError from './ValidationError';
11import reach from './util/reach';
12import isSchema from './util/isSchema';
13import setLocale from './setLocale';
14var boolean = bool;
15
16var ref = function ref(key, options) {
17 return new Ref(key, options);
18};
19
20var lazy = function lazy(fn) {
21 return new Lazy(fn);
22};
23
24function addMethod(schemaType, name, fn) {
25 if (!schemaType || !isSchema(schemaType.prototype)) throw new TypeError('You must provide a yup schema constructor function');
26 if (typeof name !== 'string') throw new TypeError('A Method name must be provided');
27 if (typeof fn !== 'function') throw new TypeError('Method function must be provided');
28 schemaType.prototype[name] = fn;
29}
30
31export { mixed, string, number, bool, boolean, date, object, array, ref, lazy, reach, isSchema, addMethod, setLocale, ValidationError };
\No newline at end of file