vtils
Version:
一个面向业务的 JavaScript/TypeScript 实用程序库。
29 lines • 1.26 kB
JavaScript
import Lazy from "./Lazy.js";
import Ref from "./Reference.js";
import ValidationError from "./ValidationError.js";
import array from "./array.js";
import bool from "./boolean.js";
import date from "./date.js";
import getLocale from "./getLocale.js";
import mixed from "./mixed.js";
import number from "./number.js";
import object from "./object.js";
import setLocale from "./setLocale.js";
import string from "./string.js";
import isSchema from "./util/isSchema.js";
import printValue from "./util/printValue.js";
import reach from "./util/reach.js";
var _boolean = bool;
var ref = function ref(key, options) {
return new Ref(key, options);
};
var lazy = function lazy(fn) {
return 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 as boolean, date, object, array, ref, lazy, reach, isSchema, addMethod, setLocale, getLocale, printValue, ValidationError };