@akinon/akival 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +24 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +3 -0
- package/package.json +16 -9
- package/dist/index.cjs +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2026
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1E,OAAO,EACL,KAAK,EACL,WAAW,EACX,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,GAAG,EACH,MAAM,EACN,MAAM,EACN,YAAY,EACb,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,MAAM,MAAM,KAAK,CAAC;AAE9B,OAAO,EACL,MAAM,EACN,KAAK,EACL,WAAW,EACX,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,GAAG,EACH,MAAM,EACN,MAAM,EACN,YAAY,EACb,CAAC;AAEF,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringSchema = exports.string = exports.Schema = exports.ref = exports.ObjectSchema = exports.object = exports.NumberSchema = exports.number = exports.MixedSchema = exports.mixed = exports.lazy = exports.DateSchema = exports.date = exports.BooleanSchema = exports.boolean = exports.bool = exports.ArraySchema = exports.array = exports.akival = void 0;
|
|
4
|
+
const yup_1 = require("yup");
|
|
5
|
+
Object.defineProperty(exports, "array", { enumerable: true, get: function () { return yup_1.array; } });
|
|
6
|
+
Object.defineProperty(exports, "ArraySchema", { enumerable: true, get: function () { return yup_1.ArraySchema; } });
|
|
7
|
+
Object.defineProperty(exports, "bool", { enumerable: true, get: function () { return yup_1.bool; } });
|
|
8
|
+
Object.defineProperty(exports, "boolean", { enumerable: true, get: function () { return yup_1.boolean; } });
|
|
9
|
+
Object.defineProperty(exports, "BooleanSchema", { enumerable: true, get: function () { return yup_1.BooleanSchema; } });
|
|
10
|
+
Object.defineProperty(exports, "date", { enumerable: true, get: function () { return yup_1.date; } });
|
|
11
|
+
Object.defineProperty(exports, "DateSchema", { enumerable: true, get: function () { return yup_1.DateSchema; } });
|
|
12
|
+
Object.defineProperty(exports, "lazy", { enumerable: true, get: function () { return yup_1.lazy; } });
|
|
13
|
+
Object.defineProperty(exports, "mixed", { enumerable: true, get: function () { return yup_1.mixed; } });
|
|
14
|
+
Object.defineProperty(exports, "MixedSchema", { enumerable: true, get: function () { return yup_1.MixedSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "number", { enumerable: true, get: function () { return yup_1.number; } });
|
|
16
|
+
Object.defineProperty(exports, "NumberSchema", { enumerable: true, get: function () { return yup_1.NumberSchema; } });
|
|
17
|
+
Object.defineProperty(exports, "object", { enumerable: true, get: function () { return yup_1.object; } });
|
|
18
|
+
Object.defineProperty(exports, "ObjectSchema", { enumerable: true, get: function () { return yup_1.ObjectSchema; } });
|
|
19
|
+
Object.defineProperty(exports, "ref", { enumerable: true, get: function () { return yup_1.ref; } });
|
|
20
|
+
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return yup_1.Schema; } });
|
|
21
|
+
Object.defineProperty(exports, "string", { enumerable: true, get: function () { return yup_1.string; } });
|
|
22
|
+
Object.defineProperty(exports, "StringSchema", { enumerable: true, get: function () { return yup_1.StringSchema; } });
|
|
23
|
+
const akival = require("yup");
|
|
24
|
+
exports.akival = akival;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AnyObjectSchema, AnySchema, InferType, ISchema } from 'yup';
|
|
2
|
+
import { array, ArraySchema, bool, boolean, BooleanSchema, date, DateSchema, lazy, mixed, MixedSchema, number, NumberSchema, object, ObjectSchema, ref, Schema, string, StringSchema } from 'yup';
|
|
3
|
+
import * as akival from 'yup';
|
|
4
|
+
export { akival, array, ArraySchema, bool, boolean, BooleanSchema, date, DateSchema, lazy, mixed, MixedSchema, number, NumberSchema, object, ObjectSchema, ref, Schema, string, StringSchema };
|
|
5
|
+
export type { AnyObjectSchema, AnySchema, InferType, ISchema };
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1E,OAAO,EACL,KAAK,EACL,WAAW,EACX,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,GAAG,EACH,MAAM,EACN,MAAM,EACN,YAAY,EACb,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,MAAM,MAAM,KAAK,CAAC;AAE9B,OAAO,EACL,MAAM,EACN,KAAK,EACL,WAAW,EACX,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,GAAG,EACH,MAAM,EACN,MAAM,EACN,YAAY,EACb,CAAC;AAEF,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { array, ArraySchema, bool, boolean, BooleanSchema, date, DateSchema, lazy, mixed, MixedSchema, number, NumberSchema, object, ObjectSchema, ref, Schema, string, StringSchema } from 'yup';
|
|
2
|
+
import * as akival from 'yup';
|
|
3
|
+
export { akival, array, ArraySchema, bool, boolean, BooleanSchema, date, DateSchema, lazy, mixed, MixedSchema, number, NumberSchema, object, ObjectSchema, ref, Schema, string, StringSchema };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/akival",
|
|
3
3
|
"description": "Object schema builder and validation library.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"module": "dist/index.js",
|
|
7
|
+
"main": "dist/esm/index.js",
|
|
8
|
+
"module": "dist/esm/index.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
@@ -14,22 +14,29 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"clean-package": "2.2.0",
|
|
17
|
-
"
|
|
17
|
+
"copyfiles": "^2.4.1",
|
|
18
|
+
"rimraf": "^5.0.5",
|
|
19
|
+
"typescript": "^5.2.2",
|
|
20
|
+
"@akinon/vite-config": "0.2.0",
|
|
18
21
|
"@akinon/typescript-config": "0.0.0",
|
|
19
22
|
"@akinon/eslint-config": "0.1.0"
|
|
20
23
|
},
|
|
21
24
|
"clean-package": "../../clean-package.config.json",
|
|
22
|
-
"types": "dist/index.d.ts",
|
|
25
|
+
"types": "dist/esm/index.d.ts",
|
|
23
26
|
"exports": {
|
|
24
27
|
".": {
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
26
|
-
"import": "./dist/index.js",
|
|
27
|
-
"require": "./dist/index.
|
|
28
|
+
"types": "./dist/esm/index.d.ts",
|
|
29
|
+
"import": "./dist/esm/index.js",
|
|
30
|
+
"require": "./dist/cjs/index.js"
|
|
28
31
|
},
|
|
29
32
|
"./package.json": "./package.json"
|
|
30
33
|
},
|
|
31
34
|
"scripts": {
|
|
32
|
-
"build": "
|
|
35
|
+
"build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
|
|
36
|
+
"build:esm": "tsc --outDir dist/esm",
|
|
37
|
+
"build:commonjs": "tsc --module commonjs --outDir dist/cjs",
|
|
38
|
+
"copy:files": "copyfiles -u 1 src/**/*.css dist/esm && copyfiles -u 1 src/**/*.css dist/cjs",
|
|
39
|
+
"clean": "rimraf dist/",
|
|
33
40
|
"lint": "eslint *.ts*",
|
|
34
41
|
"test": "vitest run",
|
|
35
42
|
"test:ui": "vitest --ui",
|
package/dist/index.cjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ze(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function k(n){this._maxSize=n,this.clear()}k.prototype.clear=function(){this._size=0,this._values=Object.create(null)};k.prototype.get=function(n){return this._values[n]};k.prototype.set=function(n,e){return this._size>=this._maxSize&&this.clear(),n in this._values||this._size++,this._values[n]=e};var Ye=/[^.^\]^[]+|(?=\[\]|\.\.)/g,De=/^\d+$/,Ge=/^\d/,Xe=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,Be=/^\s*(['"]?)(.*?)(\1)\s*$/,ae=512,Ee=new k(ae),$e=new k(ae),Oe=new k(ae),S={Cache:k,split:ne,normalizePath:te,setter:function(n){var e=te(n);return $e.get(n)||$e.set(n,function(r,s){for(var i=0,u=e.length,a=r;i<u-1;){var l=e[i];if(l==="__proto__"||l==="constructor"||l==="prototype")return r;a=a[e[i++]]}a[e[i]]=s})},getter:function(n,e){var t=te(n);return Oe.get(n)||Oe.set(n,function(s){for(var i=0,u=t.length;i<u;)if(s!=null||!e)s=s[t[i++]];else return;return s})},join:function(n){return n.reduce(function(e,t){return e+(le(t)||De.test(t)?"["+t+"]":(e?".":"")+t)},"")},forEach:function(n,e,t){He(Array.isArray(n)?n:ne(n),e,t)}};function te(n){return Ee.get(n)||Ee.set(n,ne(n).map(function(e){return e.replace(Be,"$2")}))}function ne(n){return n.match(Ye)||[""]}function He(n,e,t){var r=n.length,s,i,u,a;for(i=0;i<r;i++)s=n[i],s&&(Qe(s)&&(s='"'+s+'"'),a=le(s),u=!a&&/^\d+$/.test(s),e.call(t,s,a,u,i,n))}function le(n){return typeof n=="string"&&n&&["'",'"'].indexOf(n.charAt(0))!==-1}function Ke(n){return n.match(Ge)&&!n.match(De)}function Je(n){return Xe.test(n)}function Qe(n){return!le(n)&&(Ke(n)||Je(n))}const We=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,q=n=>n.match(We)||[],Z=n=>n[0].toUpperCase()+n.slice(1),oe=(n,e)=>q(n).join(e).toLowerCase(),je=n=>q(n).reduce((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`,""),et=n=>Z(je(n)),tt=n=>oe(n,"_"),rt=n=>oe(n,"-"),nt=n=>Z(oe(n," ")),st=n=>q(n).map(Z).join(" ");var re={words:q,upperFirst:Z,camelCase:je,pascalCase:et,snakeCase:tt,kebabCase:rt,sentenceCase:nt,titleCase:st},ce={exports:{}};ce.exports=function(n){return Ce(it(n),n)};ce.exports.array=Ce;function Ce(n,e){var t=n.length,r=new Array(t),s={},i=t,u=ut(e),a=at(n);for(e.forEach(function(o){if(!a.has(o[0])||!a.has(o[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});i--;)s[i]||l(n[i],i,new Set);return r;function l(o,f,c){if(c.has(o)){var h;try{h=", node was:"+JSON.stringify(o)}catch{h=""}throw new Error("Cyclic dependency"+h)}if(!a.has(o))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(o));if(!s[f]){s[f]=!0;var d=u.get(o)||new Set;if(d=Array.from(d),f=d.length){c.add(o);do{var x=d[--f];l(x,a.get(x),c)}while(f);c.delete(o)}r[--t]=o}}}function it(n){for(var e=new Set,t=0,r=n.length;t<r;t++){var s=n[t];e.add(s[0]),e.add(s[1])}return Array.from(e)}function ut(n){for(var e=new Map,t=0,r=n.length;t<r;t++){var s=n[t];e.has(s[0])||e.set(s[0],new Set),e.has(s[1])||e.set(s[1],new Set),e.get(s[0]).add(s[1])}return e}function at(n){for(var e=new Map,t=0,r=n.length;t<r;t++)e.set(n[t],t);return e}var lt=ce.exports;const ot=Ze(lt),ct=Object.prototype.toString,ft=Error.prototype.toString,ht=RegExp.prototype.toString,dt=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",pt=/^Symbol\((.*)\)(.*)$/;function mt(n){return n!=+n?"NaN":n===0&&1/n<0?"-0":""+n}function Se(n,e=!1){if(n==null||n===!0||n===!1)return""+n;const t=typeof n;if(t==="number")return mt(n);if(t==="string")return e?`"${n}"`:n;if(t==="function")return"[Function "+(n.name||"anonymous")+"]";if(t==="symbol")return dt.call(n).replace(pt,"Symbol($1)");const r=ct.call(n).slice(8,-1);return r==="Date"?isNaN(n.getTime())?""+n:n.toISOString(n):r==="Error"||n instanceof Error?"["+ft.call(n)+"]":r==="RegExp"?ht.call(n):null}function _(n,e){let t=Se(n,e);return t!==null?t:JSON.stringify(n,function(r,s){let i=Se(this[r],e);return i!==null?i:s},2)}function Ne(n){return n==null?[]:[].concat(n)}let ze,yt=/\$\{\s*(\w+)\s*\}/g;ze=Symbol.toStringTag;class y extends Error{static formatError(e,t){const r=t.label||t.path||"this";return r!==t.path&&(t=Object.assign({},t,{path:r})),typeof e=="string"?e.replace(yt,(s,i)=>_(t[i])):typeof e=="function"?e(t):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,t,r,s,i){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this[ze]="Error",this.name="ValidationError",this.value=t,this.path=r,this.type=s,this.errors=[],this.inner=[],Ne(e).forEach(u=>{if(y.isError(u)){this.errors.push(...u.errors);const a=u.inner.length?u.inner:[u];this.inner.push(...a)}else this.errors.push(u)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],!i&&Error.captureStackTrace&&Error.captureStackTrace(this,y)}}let w={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:n,type:e,value:t,originalValue:r})=>{const s=r!=null&&r!==t?` (cast from the value \`${_(r,!0)}\`).`:".";return e!=="mixed"?`${n} must be a \`${e}\` type, but the final value was: \`${_(t,!0)}\``+s:`${n} must match the configured type. The validated value was: \`${_(t,!0)}\``+s}},g={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},E={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},se={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},ie={isValue:"${path} field must be ${value}"},ue={noUnknown:"${path} field has unspecified keys: ${unknown}"},R={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},Me={notType:n=>{const{path:e,value:t,spec:r}=n,s=r.types.length;if(Array.isArray(t)){if(t.length<s)return`${e} tuple value has too few items, expected a length of ${s} but got ${t.length} for value: \`${_(t,!0)}\``;if(t.length>s)return`${e} tuple value has too many items, expected a length of ${s} but got ${t.length} for value: \`${_(t,!0)}\``}return y.formatError(w.notType,n)}};var Ve=Object.assign(Object.create(null),{mixed:w,string:g,number:E,date:se,object:ue,array:R,boolean:ie,tuple:Me});const A=n=>n&&n.__isYupSchema__;class U{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:r,then:s,otherwise:i}=t,u=typeof r=="function"?r:(...a)=>a.every(l=>l===r);return new U(e,(a,l)=>{var o;let f=u(...a)?s:i;return(o=f==null?void 0:f(l))!=null?o:l})}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let r=this.refs.map(i=>i.getValue(t==null?void 0:t.value,t==null?void 0:t.parent,t==null?void 0:t.context)),s=this.fn(r,e,t);if(s===void 0||s===e)return e;if(!A(s))throw new TypeError("conditions must return a schema object");return s.resolve(t)}}const P={context:"$",value:"."};function Pe(n,e){return new $(n,e)}class ${constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===P.context,this.isValue=this.key[0]===P.value,this.isSibling=!this.isContext&&!this.isValue;let r=this.isContext?P.context:this.isValue?P.value:"";this.path=this.key.slice(r.length),this.getter=this.path&&S.getter(this.path,!0),this.map=t.map}getValue(e,t,r){let s=this.isContext?r:this.isValue?e:t;return this.getter&&(s=this.getter(s||{})),this.map&&(s=this.map(s)),s}cast(e,t){return this.getValue(e,t==null?void 0:t.parent,t==null?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}$.prototype.__isYupRef=!0;const v=n=>n==null;function C(n){function e({value:t,path:r="",options:s,originalValue:i,schema:u},a,l){const{name:o,test:f,params:c,message:h,skipAbsent:d}=n;let{parent:x,context:b,abortEarly:F=u.spec.abortEarly,disableStackTrace:M=u.spec.disableStackTrace}=s;function O(p){return $.isRef(p)?p.getValue(t,x,b):p}function ge(p={}){var _e;const j=Object.assign({value:t,originalValue:i,label:u.spec.label,path:p.path||r,spec:u.spec},c,p.params);for(const Fe of Object.keys(j))j[Fe]=O(j[Fe]);const Te=new y(y.formatError(p.message||h,j),t,j.path,p.type||o,(_e=p.disableStackTrace)!=null?_e:M);return Te.params=j,Te}const Q=F?a:l;let W={path:r,parent:x,type:o,from:s.from,createError:ge,resolve:O,options:s,originalValue:i,schema:u};const ee=p=>{y.isError(p)?Q(p):p?l(null):Q(ge())},ve=p=>{y.isError(p)?Q(p):a(p)};if(d&&v(t))return ee(!0);let V;try{var we;if(V=f.call(W,t,W),typeof((we=V)==null?void 0:we.then)=="function"){if(s.sync)throw new Error(`Validation test of type: "${W.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(V).then(ee,ve)}}catch(p){ve(p);return}ee(V)}return e.OPTIONS=n,e}function fe(n,e,t,r=t){let s,i,u;return e?(S.forEach(e,(a,l,o)=>{let f=l?a.slice(1,a.length-1):a;n=n.resolve({context:r,parent:s,value:t});let c=n.type==="tuple",h=o?parseInt(f,10):0;if(n.innerType||c){if(c&&!o)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${u}" must contain an index to the tuple element, e.g. "${u}[0]"`);if(t&&h>=t.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);s=t,t=t&&t[h],n=c?n.spec.types[h]:n.innerType}if(!o){if(!n.fields||!n.fields[f])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${u} which is a type: "${n.type}")`);s=t,t=t&&t[f],n=n.fields[f]}i=f,u=l?"["+a+"]":"."+a}),{schema:n,parent:s,parentPath:i}):{parent:s,parentPath:e,schema:n}}function bt(n,e,t,r){return fe(n,e,t,r).schema}class L extends Set{describe(){const e=[];for(const t of this.values())e.push($.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const r of this.values())t.push(e(r));return t}clone(){return new L(this.values())}merge(e,t){const r=this.clone();return e.forEach(s=>r.add(s)),t.forEach(s=>r.delete(s)),r}}function N(n,e=new Map){if(A(n)||!n||typeof n!="object")return n;if(e.has(n))return e.get(n);let t;if(n instanceof Date)t=new Date(n.getTime()),e.set(n,t);else if(n instanceof RegExp)t=new RegExp(n),e.set(n,t);else if(Array.isArray(n)){t=new Array(n.length),e.set(n,t);for(let r=0;r<n.length;r++)t[r]=N(n[r],e)}else if(n instanceof Map){t=new Map,e.set(n,t);for(const[r,s]of n.entries())t.set(r,N(s,e))}else if(n instanceof Set){t=new Set,e.set(n,t);for(const r of n)t.add(N(r,e))}else if(n instanceof Object){t={},e.set(n,t);for(const[r,s]of Object.entries(n))t[r]=N(s,e)}else throw Error(`Unable to clone ${n}`);return t}class m{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new L,this._blacklist=new L,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(w.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},e==null?void 0:e.spec),this.withMutation(t=>{t.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=N(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(e.length===0)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let r=e(this);return this._mutate=t,r}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,r=e.clone();const s=Object.assign({},t.spec,r.spec);return r.spec=s,r.internalTests=Object.assign({},t.internalTests,r.internalTests),r._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),r._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),r.tests=t.tests,r.exclusiveTests=t.exclusiveTests,r.withMutation(i=>{e.tests.forEach(u=>{i.test(u.OPTIONS)})}),r.transforms=[...t.transforms,...r.transforms],r}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let r=t.conditions;t=t.clone(),t.conditions=[],t=r.reduce((s,i)=>i.resolve(s,e),t),t=t.resolve(e)}return t}resolveOptions(e){var t,r,s,i;return Object.assign({},e,{from:e.from||[],strict:(t=e.strict)!=null?t:this.spec.strict,abortEarly:(r=e.abortEarly)!=null?r:this.spec.abortEarly,recursive:(s=e.recursive)!=null?s:this.spec.recursive,disableStackTrace:(i=e.disableStackTrace)!=null?i:this.spec.disableStackTrace})}cast(e,t={}){let r=this.resolve(Object.assign({value:e},t)),s=t.assert==="ignore-optionality",i=r._cast(e,t);if(t.assert!==!1&&!r.isType(i)){if(s&&v(i))return i;let u=_(e),a=_(i);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${r.type}".
|
|
2
|
-
|
|
3
|
-
attempted value: ${u}
|
|
4
|
-
`+(a!==u?`result of cast: ${a}`:""))}return i}_cast(e,t){let r=e===void 0?e:this.transforms.reduce((s,i)=>i.call(this,s,e,this),e);return r===void 0&&(r=this.getDefault(t)),r}_validate(e,t={},r,s){let{path:i,originalValue:u=e,strict:a=this.spec.strict}=t,l=e;a||(l=this._cast(l,Object.assign({assert:!1},t)));let o=[];for(let f of Object.values(this.internalTests))f&&o.push(f);this.runTests({path:i,value:l,originalValue:u,options:t,tests:o},r,f=>{if(f.length)return s(f,l);this.runTests({path:i,value:l,originalValue:u,options:t,tests:this.tests},r,s)})}runTests(e,t,r){let s=!1,{tests:i,value:u,originalValue:a,path:l,options:o}=e,f=b=>{s||(s=!0,t(b,u))},c=b=>{s||(s=!0,r(b,u))},h=i.length,d=[];if(!h)return c([]);let x={value:u,originalValue:a,path:l,options:o,schema:this};for(let b=0;b<i.length;b++){const F=i[b];F(x,f,function(O){O&&(Array.isArray(O)?d.push(...O):d.push(O)),--h<=0&&c(d)})}}asNestedTest({key:e,index:t,parent:r,parentPath:s,originalParent:i,options:u}){const a=e??t;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let o=r[a];const f=Object.assign({},u,{strict:!0,parent:r,value:o,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${s||""}[${o?a:`"${a}"`}]`:(s?`${s}.`:"")+e});return(c,h,d)=>this.resolve(f)._validate(o,f,h,d)}validate(e,t){var r;let s=this.resolve(Object.assign({},t,{value:e})),i=(r=t==null?void 0:t.disableStackTrace)!=null?r:s.spec.disableStackTrace;return new Promise((u,a)=>s._validate(e,t,(l,o)=>{y.isError(l)&&(l.value=o),a(l)},(l,o)=>{l.length?a(new y(l,o,void 0,void 0,i)):u(o)}))}validateSync(e,t){var r;let s=this.resolve(Object.assign({},t,{value:e})),i,u=(r=t==null?void 0:t.disableStackTrace)!=null?r:s.spec.disableStackTrace;return s._validate(e,Object.assign({},t,{sync:!0}),(a,l)=>{throw y.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new y(a,e,void 0,void 0,u);i=l}),i}isValid(e,t){return this.validate(e,t).then(()=>!0,r=>{if(y.isError(r))return!1;throw r})}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(r){if(y.isError(r))return!1;throw r}}_getDefault(e){let t=this.spec.default;return t==null?t:typeof t=="function"?t.call(this,e):N(t)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const r=this.clone({nullable:e});return r.internalTests.nullable=C({message:t,name:"nullable",test(s){return s===null?this.schema.spec.nullable:!0}}),r}optionality(e,t){const r=this.clone({optional:e});return r.internalTests.optionality=C({message:t,name:"optionality",test(s){return s===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=w.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=w.notNull){return this.nullability(!1,e)}required(e=w.required){return this.clone().withMutation(t=>t.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(e.length===1?typeof e[0]=="function"?t={test:e[0]}:t=e[0]:e.length===2?t={name:e[0],test:e[1]}:t={name:e[0],message:e[1],test:e[2]},t.message===void 0&&(t.message=w.default),typeof t.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),s=C(t),i=t.exclusive||t.name&&r.exclusiveTests[t.name]===!0;if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(r.exclusiveTests[t.name]=!!t.exclusive),r.tests=r.tests.filter(u=>!(u.OPTIONS.name===t.name&&(i||u.OPTIONS.test===s.OPTIONS.test))),r.tests.push(s),r}when(e,t){!Array.isArray(e)&&typeof e!="string"&&(t=e,e=".");let r=this.clone(),s=Ne(e).map(i=>new $(i));return s.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof t=="function"?new U(s,t):U.fromOptions(s,t)),r}typeError(e){let t=this.clone();return t.internalTests.typeError=C({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),t}oneOf(e,t=w.oneOf){let r=this.clone();return e.forEach(s=>{r._whitelist.add(s),r._blacklist.delete(s)}),r.internalTests.whiteList=C({message:t,name:"oneOf",skipAbsent:!0,test(s){let i=this.schema._whitelist,u=i.resolveAll(this.resolve);return u.includes(s)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:u}})}}),r}notOneOf(e,t=w.notOneOf){let r=this.clone();return e.forEach(s=>{r._blacklist.add(s),r._whitelist.delete(s)}),r.internalTests.blacklist=C({message:t,name:"notOneOf",test(s){let i=this.schema._blacklist,u=i.resolveAll(this.resolve);return u.includes(s)?this.createError({params:{values:Array.from(i).join(", "),resolved:u}}):!0}}),r}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:r,meta:s,optional:i,nullable:u}=t.spec;return{meta:s,label:r,optional:i,nullable:u,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map(l=>({name:l.OPTIONS.name,params:l.OPTIONS.params})).filter((l,o,f)=>f.findIndex(c=>c.name===l.name)===o)}}}m.prototype.__isYupSchema__=!0;for(const n of["validate","validateSync"])m.prototype[`${n}At`]=function(e,t,r={}){const{parent:s,parentPath:i,schema:u}=fe(this,e,t,r.context);return u[n](s&&s[i],Object.assign({},r,{parent:s,path:e}))};for(const n of["equals","is"])m.prototype[n]=m.prototype.oneOf;for(const n of["not","nope"])m.prototype[n]=m.prototype.notOneOf;const xt=()=>!0;function he(n){return new Y(n)}class Y extends m{constructor(e){super(typeof e=="function"?{type:"mixed",check:e}:Object.assign({type:"mixed",check:xt},e))}}he.prototype=Y.prototype;function z(){return new G}class G extends m{constructor(){super({type:"boolean",check(e){return e instanceof Boolean&&(e=e.valueOf()),typeof e=="boolean"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(r.spec.coerce&&!r.isType(e)){if(/^(true|1)$/i.test(String(e)))return!0;if(/^(false|0)$/i.test(String(e)))return!1}return e})})}isTrue(e=ie.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"true"},test(t){return v(t)||t===!0}})}isFalse(e=ie.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"false"},test(t){return v(t)||t===!1}})}default(e){return super.default(e)}defined(e){return super.defined(e)}optional(){return super.optional()}required(e){return super.required(e)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(e){return super.nonNullable(e)}strip(e){return super.strip(e)}}z.prototype=G.prototype;let gt=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,vt=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,wt=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,_t=n=>v(n)||n===n.trim(),Tt={}.toString();function de(){return new X}class X extends m{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce||r.isType(e)||Array.isArray(e))return e;const s=e!=null&&e.toString?e.toString():e;return s===Tt?e:s})})}required(e){return super.required(e).withMutation(t=>t.test({message:e||w.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(t=>t.OPTIONS.name!=="required"),e))}length(e,t=g.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t=g.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t=g.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,t){let r=!1,s,i;return t&&(typeof t=="object"?{excludeEmptyString:r=!1,message:s,name:i}=t:s=t),this.test({name:i||"matches",message:s||g.matches,params:{regex:e},skipAbsent:!0,test:u=>u===""&&r||u.search(e)!==-1})}email(e=g.email){return this.matches(gt,{name:"email",message:e,excludeEmptyString:!0})}url(e=g.url){return this.matches(vt,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=g.uuid){return this.matches(wt,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=g.trim){return this.transform(t=>t!=null?t.trim():t).test({message:e,name:"trim",test:_t})}lowercase(e=g.lowercase){return this.transform(t=>v(t)?t:t.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>v(t)||t===t.toLowerCase()})}uppercase(e=g.uppercase){return this.transform(t=>v(t)?t:t.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>v(t)||t===t.toUpperCase()})}}de.prototype=X.prototype;let Ft=n=>n!=+n;function pe(){return new B}class B extends m{constructor(){super({type:"number",check(e){return e instanceof Number&&(e=e.valueOf()),typeof e=="number"&&!Ft(e)}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce)return e;let s=e;if(typeof s=="string"){if(s=s.replace(/\s/g,""),s==="")return NaN;s=+s}return r.isType(s)||s===null?s:parseFloat(s)})})}min(e,t=E.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r>=this.resolve(e)}})}max(e,t=E.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r<=this.resolve(e)}})}lessThan(e,t=E.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(r){return r<this.resolve(e)}})}moreThan(e,t=E.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(r){return r>this.resolve(e)}})}positive(e=E.positive){return this.moreThan(0,e)}negative(e=E.negative){return this.lessThan(0,e)}integer(e=E.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:t=>Number.isInteger(t)})}truncate(){return this.transform(e=>v(e)?e:e|0)}round(e){var t;let r=["ceil","floor","round","trunc"];if(e=((t=e)==null?void 0:t.toLowerCase())||"round",e==="trunc")return this.truncate();if(r.indexOf(e.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+r.join(", "));return this.transform(s=>v(s)?s:Math[e](s))}}pe.prototype=B.prototype;const Et=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function T(n,e=0){return Number(n)||e}function $t(n){const e=Et.exec(n);if(!e)return Date.parse?Date.parse(n):Number.NaN;const t={year:T(e[1]),month:T(e[2],1)-1,day:T(e[3],1),hour:T(e[4]),minute:T(e[5]),second:T(e[6]),millisecond:e[7]?T(e[7].substring(0,3)):0,z:e[8]||void 0,plusMinus:e[9]||void 0,hourOffset:T(e[10]),minuteOffset:T(e[11])};if(t.z===void 0&&t.plusMinus===void 0)return new Date(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond).valueOf();let r=0;return t.z!=="Z"&&t.plusMinus!==void 0&&(r=t.hourOffset*60+t.minuteOffset,t.plusMinus==="+"&&(r=0-r)),Date.UTC(t.year,t.month,t.day,t.hour,t.minute+r,t.second,t.millisecond)}let Re=new Date(""),Ot=n=>Object.prototype.toString.call(n)==="[object Date]";function H(){return new D}class D extends m{constructor(){super({type:"date",check(e){return Ot(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,t,r)=>!r.spec.coerce||r.isType(e)||e===null?e:(e=$t(e),isNaN(e)?D.INVALID_DATE:new Date(e)))})}prepareParam(e,t){let r;if($.isRef(e))r=e;else{let s=this.cast(e);if(!this._typeCheck(s))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);r=s}return r}min(e,t=se.min){let r=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(s){return s>=this.resolve(r)}})}max(e,t=se.max){let r=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(s){return s<=this.resolve(r)}})}}D.INVALID_DATE=Re;H.prototype=D.prototype;H.INVALID_DATE=Re;function St(n,e=[]){let t=[],r=new Set,s=new Set(e.map(([u,a])=>`${u}-${a}`));function i(u,a){let l=S.split(u)[0];r.add(l),s.has(`${a}-${l}`)||t.push([a,l])}for(const u of Object.keys(n)){let a=n[u];r.add(u),$.isRef(a)&&a.isSibling?i(a.path,u):A(a)&&"deps"in a&&a.deps.forEach(l=>i(l,u))}return ot.array(Array.from(r),t).reverse()}function ke(n,e){let t=1/0;return n.some((r,s)=>{var i;if((i=e.path)!=null&&i.includes(r))return t=s,!0}),t}function Ie(n){return(e,t)=>ke(n,e)-ke(n,t)}const Ue=(n,e,t)=>{if(typeof n!="string")return n;let r=n;try{r=JSON.parse(n)}catch{}return t.isType(r)?r:n};function I(n){if("fields"in n){const e={};for(const[t,r]of Object.entries(n.fields))e[t]=I(r);return n.setFields(e)}if(n.type==="array"){const e=n.optional();return e.innerType&&(e.innerType=I(e.innerType)),e}return n.type==="tuple"?n.optional().clone({types:n.spec.types.map(I)}):"optional"in n?n.optional():n}const kt=(n,e)=>{const t=[...S.normalizePath(e)];if(t.length===1)return t[0]in n;let r=t.pop(),s=S.getter(S.join(t),!0)(n);return!!(s&&r in s)};let Ae=n=>Object.prototype.toString.call(n)==="[object Object]";function At(n,e){let t=Object.keys(n.fields);return Object.keys(e).filter(r=>t.indexOf(r)===-1)}const Dt=Ie([]);function me(n){return new K(n)}class K extends m{constructor(e){super({type:"object",check(t){return Ae(t)||typeof t=="function"}}),this.fields=Object.create(null),this._sortErrors=Dt,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,t={}){var r;let s=super._cast(e,t);if(s===void 0)return this.getDefault(t);if(!this._typeCheck(s))return s;let i=this.fields,u=(r=t.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(s).filter(c=>!this._nodes.includes(c))),l={},o=Object.assign({},t,{parent:l,__validating:t.__validating||!1}),f=!1;for(const c of a){let h=i[c],d=c in s;if(h){let x,b=s[c];o.path=(t.path?`${t.path}.`:"")+c,h=h.resolve({value:b,context:t.context,parent:l});let F=h instanceof m?h.spec:void 0,M=F==null?void 0:F.strict;if(F!=null&&F.strip){f=f||c in s;continue}x=!t.__validating||!M?h.cast(s[c],o):s[c],x!==void 0&&(l[c]=x)}else d&&!u&&(l[c]=s[c]);(d!==c in l||l[c]!==s[c])&&(f=!0)}return f?l:s}_validate(e,t={},r,s){let{from:i=[],originalValue:u=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:u},...i],t.__validating=!0,t.originalValue=u,super._validate(e,t,r,(l,o)=>{if(!a||!Ae(o)){s(l,o);return}u=u||o;let f=[];for(let c of this._nodes){let h=this.fields[c];!h||$.isRef(h)||f.push(h.asNestedTest({options:t,key:c,parent:o,parentPath:t.path,originalParent:u}))}this.runTests({tests:f,value:o,originalValue:u,options:t},r,c=>{s(c.sort(this._sortErrors).concat(l),o)})})}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),r=t.fields;for(let[s,i]of Object.entries(this.fields)){const u=r[s];r[s]=u===void 0?i:u}return t.withMutation(s=>s.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let t={};return this._nodes.forEach(r=>{var s;const i=this.fields[r];let u=e;(s=u)!=null&&s.value&&(u=Object.assign({},u,{parent:u.value,value:u.value[r]})),t[r]=i&&"getDefault"in i?i.getDefault(u):void 0}),t}setFields(e,t){let r=this.clone();return r.fields=e,r._nodes=St(e,t),r._sortErrors=Ie(Object.keys(e)),t&&(r._excludedEdges=t),r}shape(e,t=[]){return this.clone().withMutation(r=>{let s=r._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),s=[...r._excludedEdges,...t]),r.setFields(Object.assign(r.fields,e),s)})}partial(){const e={};for(const[t,r]of Object.entries(this.fields))e[t]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return I(this)}pick(e){const t={};for(const r of e)this.fields[r]&&(t[r]=this.fields[r]);return this.setFields(t,this._excludedEdges.filter(([r,s])=>e.includes(r)&&e.includes(s)))}omit(e){const t=[];for(const r of Object.keys(this.fields))e.includes(r)||t.push(r);return this.pick(t)}from(e,t,r){let s=S.getter(e,!0);return this.transform(i=>{if(!i)return i;let u=i;return kt(i,e)&&(u=Object.assign({},i),r||delete u[e],u[t]=s(i)),u})}json(){return this.transform(Ue)}noUnknown(e=!0,t=ue.noUnknown){typeof e!="boolean"&&(t=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:t,test(s){if(s==null)return!0;const i=At(this.schema,s);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,t=ue.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform(t=>{if(!t)return t;const r={};for(const s of Object.keys(t))r[e(s)]=t[s];return r})}camelCase(){return this.transformKeys(re.camelCase)}snakeCase(){return this.transformKeys(re.snakeCase)}constantCase(){return this.transformKeys(e=>re.snakeCase(e).toUpperCase())}describe(e){const t=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,u]of Object.entries(t.fields)){var s;let a=e;(s=a)!=null&&s.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=u.describe(a)}return r}}me.prototype=K.prototype;function ye(n){return new J(n)}class J extends m{constructor(e){super({type:"array",spec:{types:e},check(t){return Array.isArray(t)}}),this.innerType=void 0,this.innerType=e}_cast(e,t){const r=super._cast(e,t);if(!this._typeCheck(r)||!this.innerType)return r;let s=!1;const i=r.map((u,a)=>{const l=this.innerType.cast(u,Object.assign({},t,{path:`${t.path||""}[${a}]`}));return l!==u&&(s=!0),l});return s?i:r}_validate(e,t={},r,s){var i;let u=this.innerType,a=(i=t.recursive)!=null?i:this.spec.recursive;t.originalValue!=null&&t.originalValue,super._validate(e,t,r,(l,o)=>{var f;if(!a||!u||!this._typeCheck(o)){s(l,o);return}let c=new Array(o.length);for(let d=0;d<o.length;d++){var h;c[d]=u.asNestedTest({options:t,index:d,parent:o,parentPath:t.path,originalParent:(h=t.originalValue)!=null?h:e})}this.runTests({value:o,tests:c,originalValue:(f=t.originalValue)!=null?f:e,options:t},r,d=>s(d.concat(l),o))})}clone(e){const t=super.clone(e);return t.innerType=this.innerType,t}json(){return this.transform(Ue)}concat(e){let t=super.concat(e);return t.innerType=this.innerType,e.innerType&&(t.innerType=t.innerType?t.innerType.concat(e.innerType):e.innerType),t}of(e){let t=this.clone();if(!A(e))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+_(e));return t.innerType=e,t.spec=Object.assign({},t.spec,{types:e}),t}length(e,t=R.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t){return t=t||R.min,this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t){return t=t||R.max,this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}ensure(){return this.default(()=>[]).transform((e,t)=>this._typeCheck(e)?e:t==null?[]:[].concat(t))}compact(e){let t=e?(r,s,i)=>!e(r,s,i):r=>!!r;return this.transform(r=>r!=null?r.filter(t):r)}describe(e){const t=(e?this.resolve(e):this).clone(),r=super.describe(e);if(t.innerType){var s;let i=e;(s=i)!=null&&s.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[0]})),r.innerType=t.innerType.describe(i)}return r}}ye.prototype=J.prototype;function Le(n){return new be(n)}class be extends m{constructor(e){super({type:"tuple",spec:{types:e},check(t){const r=this.spec.types;return Array.isArray(t)&&t.length===r.length}}),this.withMutation(()=>{this.typeError(Me.notType)})}_cast(e,t){const{types:r}=this.spec,s=super._cast(e,t);if(!this._typeCheck(s))return s;let i=!1;const u=r.map((a,l)=>{const o=a.cast(s[l],Object.assign({},t,{path:`${t.path||""}[${l}]`}));return o!==s[l]&&(i=!0),o});return i?u:s}_validate(e,t={},r,s){let i=this.spec.types;super._validate(e,t,r,(u,a)=>{var l;if(!this._typeCheck(a)){s(u,a);return}let o=[];for(let[c,h]of i.entries()){var f;o[c]=h.asNestedTest({options:t,index:c,parent:a,parentPath:t.path,originalParent:(f=t.originalValue)!=null?f:e})}this.runTests({value:a,tests:o,originalValue:(l=t.originalValue)!=null?l:e,options:t},r,c=>s(c.concat(u),a))})}describe(e){const t=(e?this.resolve(e):this).clone(),r=super.describe(e);return r.innerType=t.spec.types.map((s,i)=>{var u;let a=e;return(u=a)!=null&&u.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),s.describe(a)}),r}}Le.prototype=be.prototype;function qe(n){return new xe(n)}class xe{constructor(e){this.type="lazy",this.__isYupSchema__=!0,this.spec=void 0,this._resolve=(t,r={})=>{let s=this.builder(t,r);if(!A(s))throw new TypeError("lazy() functions must return a valid schema");return this.spec.optional&&(s=s.optional()),s.resolve(r)},this.builder=e,this.spec={meta:void 0,optional:!1}}clone(e){const t=new xe(this.builder);return t.spec=Object.assign({},this.spec,e),t}optionality(e){return this.clone({optional:e})}optional(){return this.optionality(!0)}resolve(e){return this._resolve(e.value,e)}cast(e,t){return this._resolve(e,t).cast(e,t)}asNestedTest(e){let{key:t,index:r,parent:s,options:i}=e,u=s[r??t];return this._resolve(u,Object.assign({},i,{value:u,parent:s})).asNestedTest(e)}validate(e,t){return this._resolve(e,t).validate(e,t)}validateSync(e,t){return this._resolve(e,t).validateSync(e,t)}validateAt(e,t,r){return this._resolve(t,r).validateAt(e,t,r)}validateSyncAt(e,t,r){return this._resolve(t,r).validateSyncAt(e,t,r)}isValid(e,t){return this._resolve(e,t).isValid(e,t)}isValidSync(e,t){return this._resolve(e,t).isValidSync(e,t)}describe(e){return e?this.resolve(e).describe(e):{type:"lazy",meta:this.spec.meta,label:void 0}}meta(...e){if(e.length===0)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}}function jt(n){Object.keys(n).forEach(e=>{Object.keys(n[e]).forEach(t=>{Ve[e][t]=n[e][t]})})}function Ct(n,e,t){if(!n||!A(n.prototype))throw new TypeError("You must provide a yup schema constructor function");if(typeof e!="string")throw new TypeError("A Method name must be provided");if(typeof t!="function")throw new TypeError("Method function must be provided");n.prototype[e]=t}const Nt=Object.freeze(Object.defineProperty({__proto__:null,ArraySchema:J,BooleanSchema:G,DateSchema:D,MixedSchema:Y,NumberSchema:B,ObjectSchema:K,Schema:m,StringSchema:X,TupleSchema:be,ValidationError:y,addMethod:Ct,array:ye,bool:z,boolean:z,date:H,defaultLocale:Ve,getIn:fe,isSchema:A,lazy:qe,mixed:he,number:pe,object:me,printValue:_,reach:bt,ref:Pe,setLocale:jt,string:de,tuple:Le},Symbol.toStringTag,{value:"Module"}));exports.ArraySchema=J;exports.BooleanSchema=G;exports.DateSchema=D;exports.MixedSchema=Y;exports.NumberSchema=B;exports.ObjectSchema=K;exports.Schema=m;exports.StringSchema=X;exports.akival=Nt;exports.array=ye;exports.bool=z;exports.boolean=z;exports.date=H;exports.lazy=qe;exports.mixed=he;exports.number=pe;exports.object=me;exports.ref=Pe;exports.string=de;
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1E,OAAO,EACL,KAAK,EACL,WAAW,EACX,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,GAAG,EACH,MAAM,EACN,MAAM,EACN,YAAY,EACb,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,MAAM,MAAM,KAAK,CAAC;AAE9B,OAAO,EACL,MAAM,EACN,KAAK,EACL,WAAW,EACX,IAAI,EACJ,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,MAAM,EACN,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,GAAG,EACH,MAAM,EACN,MAAM,EACN,YAAY,EACb,CAAC;AAEF,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC"}
|