LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing
    • swap_horiz
      Codec
    • schema
      Standard Schema
    • format_quote
      String

    • error
      Stack

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
@paseri/paseri/Compiled (minified)Compiled (minified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/@paseri/paseri/download_compiled/minified.js
Copy to clipboardCopy to clipboard
function e(e,t){let n=[],r=new Set,i=[],a=[e,[]];for(;a;){let[e,o]=a;switch(e.type){case`leaf`:{let i;if(t===void 0)i=e.code;else{let n=t[e.code];if(n===void 0){r.add(e.code);break}let{code:a,type:o,...s}=e;i=n(s)}n.push({path:o,message:i});break}case`join`:i.push([e.right,o],[e.left,o]);break;case`nest`:i.push([e.child,[...o,e.key]]);break}a=i.pop()}if(r.size>0){let e=[...r].sort();throw Error(`No messages for codes: ${e.join(`, `)}.`)}return n}var t=class{ok=!1;_issue;constructor(e){this._issue=e}get issue(){return this._issue}messages(t){return e(this._issue,t)}},n=class extends Error{_issue;constructor(e){super("Failed to parse. See `e.messages()` for details."),this._issue=e}messages(t){return e(this._issue,t)}};function r(e){return e.ok===!0}const i={INVALID_TYPE:`invalid_type`,TOO_SHORT:`too_short`,TOO_LONG:`too_long`,DUPLICATE_KEY:`duplicate_key`,TOO_DEEP:`too_deep`,INVALID_EMAIL:`invalid_email`,INVALID_EMOJI:`invalid_emoji`,INVALID_UUID:`invalid_uuid`,INVALID_NANOID:`invalid_nanoid`,DOES_NOT_INCLUDE:`does_not_include`,DOES_NOT_START_WITH:`does_not_start_with`,DOES_NOT_END_WITH:`does_not_end_with`,INVALID_DATE_STRING:`invalid_date_string`,INVALID_TIME_STRING:`invalid_time_string`,INVALID_DATE_TIME_STRING:`invalid_date_time_string`,INVALID_IP_ADDRESS:`invalid_ip_address`,INVALID_IP_ADDRESS_RANGE:`invalid_ip_address_range`,INVALID_URL:`invalid_url`,DOES_NOT_MATCH_REGEX:`does_not_match_regex`,TOO_SMALL:`too_small`,TOO_LARGE:`too_large`,INVALID_INTEGER:`invalid_integer`,INVALID_FINITE:`invalid_finite`,INVALID_SAFE_INTEGER:`invalid_safe_integer`,INVALID_VALUE:`invalid_value`,INVALID_DISCRIMINATOR_VALUE:`invalid_discriminator_value`,INVALID_ENUM_VALUE:`invalid_enum_value`,UNRECOGNIZED_KEY:`unrecognized_key`,MISSING_VALUE:`missing_value`,INVALID_DATE:`invalid_date`,TOO_RECENT:`too_recent`,TOO_DATED:`too_dated`};function a(e,t){return e?{type:`join`,left:e,right:t}:t}function o(e){return typeof e!=`object`||!e||Array.isArray(e)?!1:e.constructor===Object?!0:e.constructor===void 0?Object.getPrototypeOf(e)===null:Object.hasOwn(e,`constructor`)?Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null:!1}function s(e,t){Object.defineProperty(e,"__proto__",{value:t,writable:!0,enumerable:!0,configurable:!0})}function c(e){return typeof e==`bigint`?`${e}n`:typeof e==`string`?`'${e}'`:String(e)}function l(e,t,n,r,i){if(e===void 0)return!1;for(let a of e)if(a.tag===t&&Math.sign(r(n,a.param))===i)return!0;return!1}function u(e){return typeof Temporal>`u`?!1:e instanceof Temporal.Instant||e instanceof Temporal.PlainDate||e instanceof Temporal.PlainDateTime||e instanceof Temporal.PlainMonthDay||e instanceof Temporal.PlainTime||e instanceof Temporal.PlainYearMonth||e instanceof Temporal.ZonedDateTime||e instanceof Temporal.Duration}function d(e){if(e===null)return e;if(typeof e==`function`||typeof e==`symbol`)throw Error(`A default value cannot be a ${typeof e}.`);if(typeof e!=`object`||u(e))return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>d(e));if(e instanceof Map){let t=new Map;for(let[n,r]of e)t.set(d(n),d(r));return t}if(e instanceof Set){let t=new Set;for(let n of e)t.add(d(n));return t}if(o(e)){let t=e,n={};for(let e of Object.keys(t))e===`__proto__`?s(n,d(t[e])):n[e]=d(t[e]);return n}let t=e.constructor?.name??`non-plain object`;throw Error(`A default value cannot be a ${t}.`)}function f(e){if(typeof e!=`object`||!e||Object.isFrozen(e))return e;if(e instanceof Map||e instanceof Set){if(e instanceof Map)for(let[t,n]of e)f(t),f(n);else for(let t of e)f(t);let t=()=>{throw TypeError(`Cannot mutate a frozen default value.`)},n=e instanceof Map?[`set`,`delete`,`clear`]:[`add`,`delete`,`clear`];for(let r of n)Object.defineProperty(e,r,{value:t,writable:!1,enumerable:!1,configurable:!1})}Object.freeze(e);for(let t of Reflect.ownKeys(e))f(e[t]);return e}var p;const m=1e3;p=`~standard`;var h=class{get[p](){let e=this;return{version:1,vendor:`paseri`,validate(t,n){let r=e.safeParse(t);return r.ok?{value:r.value}:{issues:r.messages(n?.libraryOptions?.locale)}}}}_isOptional(){return!1}_hasDefault(){return!1}_unwrapOptional(){return this}_unwrapRefine(){return this}parse(e,t){let i=t?.maxDepth??m;if(!Number.isInteger(i)||i<1)throw Error(`maxDepth must be a positive integer.`);let a=this._parse(e,0,i);if(a===void 0)return e;if(r(a))return a.value;throw new n(a)}safeParse(e,n){let i=n?.maxDepth??m;if(!Number.isInteger(i)||i<1)throw Error(`maxDepth must be a positive integer.`);let a=this._parse(e,0,i);return a===void 0?{ok:!0,value:e}:r(a)?a:new t(a)}optional(){return new g(this)}nullable(){return new _(this)}chain(e,t){return new v(this,e,t)}refine(e,t){return new b(this,e,t)}},g=class e extends h{_schema;constructor(e){super(),this._schema=e}_clone(){return new e(this._schema)}_parse(e,t,n){if(e!==void 0)return this._schema._parse(e,t,n)}_isOptional(){return!0}_unwrapOptional(){return this._schema}default(e){return new y(this._schema,e)}},_=class e extends h{_schema;constructor(e){super(),this._schema=e}_clone(){return new e(this._schema)}_parse(e,t,n){if(e!==null)return this._schema._parse(e,t,n)}_isOptional(){return this._schema._isOptional()}_hasDefault(){return this._schema._hasDefault()}_unwrapOptional(){return new e(this._schema._unwrapOptional())}},v=class extends h{_fromSchema;_toSchema;_transformer;constructor(e,t,n){super(),this._fromSchema=e,this._toSchema=t,this._transformer=n}_clone(){return this}_parse(e,t,n){let i=this._fromSchema._parse(e,t,n),a=this._transformer,o;if(i===void 0)o=a(e);else if(r(i))o=a(i.value);else return i;if(!o.ok)return o.issue;let s=this._toSchema._parse(o.value,t,n);return s===void 0?{ok:!0,value:o.value}:s}},y=class e extends h{_schema;_default;constructor(e,t){super(),this._schema=e,this._default=f(d(t))}_clone(){return new e(this._schema,this._default)}_parse(e,t,n){return e===void 0?{ok:!0,value:this._default}:this._schema._parse(e,t,n)}_getDefault(){return this._default}_hasDefault(){return!0}},b=class e extends h{_base;_predicate;_code;_path;_params;constructor(e,t,n){super(),this._base=e,this._predicate=t,this._code=n.code,this._path=n.path??[],this._params=n.params}_clone(){return this}_isOptional(){return this._base._isOptional()}_hasDefault(){return this._base._hasDefault()}_unwrapRefine(){return this._base._unwrapRefine()}_unwrapOptional(){let t=new e(this._base._unwrapOptional(),this._predicate,{code:this._code,path:[...this._path],...this._params!==void 0&&{params:this._params}});return t._callSiteFile=this._callSiteFile,t}_parse(e,t,n){let i=this._base._parse(e,t,n);if(i!==void 0&&!r(i))return i;let a=i===void 0?e:i.value,o=this._predicate;if(o(a))return i;let s={type:`leaf`,code:this._code,...this._params!==void 0&&{params:this._params}};for(let e=this._path.length-1;e>=0;e--)s={type:`nest`,key:this._path[e],child:s};return s}},x=class e extends h{_element;_minLength=0;_maxLength=1/0;issues={INVALID_TYPE:{type:`leaf`,code:i.INVALID_TYPE,expected:`array`},TOO_LONG:{type:`leaf`,code:i.TOO_LONG},TOO_SHORT:{type:`leaf`,code:i.TOO_SHORT}};constructor(e){super(),this._element=e}_clone(){let t=new e(this._element);return t._minLength=this._minLength,t._maxLength=this._maxLength,t}_parse(e,t,n){if(!Array.isArray(e))return this.issues.INVALID_TYPE;let i=e.length,o=this._maxLength,s=this._minLength;if(i>o)return this.issues.TOO_LONG;if(i<s)return this.issues.TOO_SHORT;let c=this._element,l,u;for(let o=0;o<i;o++){let i=e[o],s=c._parse(i,t,n);if(s===void 0){u?.push(i);continue}r(s)?(u||=e.slice(0,o),u.push(s.value)):(u?.push(i),l=a(l,{type:`nest`,key:o,child:s}))}if(l)return l;if(u)return{ok:!0,value:u}}min(e){if(!Number.isInteger(e)||e<0)throw Error(`Length must be a non-negative integer.`);if(e>this._maxLength)throw Error(`Minimum length must not exceed maximum length.`);let t=this._clone();return t._minLength=e,t}max(e){if(!Number.isInteger(e)||e<0)throw Error(`Length must be a non-negative integer.`);if(e<this._minLength)throw Error(`Minimum length must not exceed maximum length.`);let t=this._clone();return t._maxLength=e,t}length(e){if(!Number.isInteger(e)||e<0)throw Error(`Length must be a non-negative integer.`);let t=this._clone();return t._minLength=e,t._maxLength=e,t}};const S=(...e)=>new x(...e);function C(e,t,n){if(e===void 0)return;let r;for(let i of e)(i.tag===t||i.tag===n)&&(r===void 0||i.param>r)&&(r=i.param);if(r===void 0)return;let i=!1;for(let t of e)t.tag===n&&t.param===r&&(i=!0);return{value:r,strict:i}}function w(e,t,n){if(e===void 0)return;let r;for(let i of e)(i.tag===t||i.tag===n)&&(r===void 0||i.param<r)&&(r=i.param);if(r===void 0)return;let i=!1;for(let t of e)t.tag===n&&t.param===r&&(i=!0);return{value:r,strict:i}}function T(e,t,n){if(e!==void 0&&(t>e.value||t===e.value&&(n||e.strict)))throw Error(`Lower bound must not exceed upper bound.`)}function E(e,t,n){if(e!==void 0&&(t<e.value||t===e.value&&(n||e.strict)))throw Error(`Lower bound must not exceed upper bound.`)}const D=new class e extends h{_checks=void 0;issues={INVALID_TYPE:{type:`leaf`,code:i.INVALID_TYPE,expected:`Date`},INVALID_DATE:{type:`leaf`,code:i.INVALID_DATE},TOO_DATED:{type:`leaf`,code:i.TOO_DATED},TOO_RECENT:{type:`leaf`,code:i.TOO_RECENT}};_clone(){let t=new e;return t._checks=this._checks?.slice(),t}_parse(e,t,n){if(!(e instanceof Date))return this.issues.INVALID_TYPE;if(Number.isNaN(e.getTime()))return this.issues.INVALID_DATE;if(this._checks!==void 0){let t=this._checks;for(let n=0;n<t.length;n++){let{tag:r,param:i,issue:a}=t[n];switch(r){case 0:if(e<i)return a;break;case 1:if(e>i)return a;break}}}}min(e){if(Number.isNaN(e.getTime()))throw Error(`Invalid Date is not a valid boundary value.`);if(l(this._checks,1,e,(e,t)=>e.getTime()-t.getTime(),1))throw Error(`Minimum must not exceed maximum.`);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:0,param:new Date(e.getTime()),issue:this.issues.TOO_DATED}),t}max(e){if(Number.isNaN(e.getTime()))throw Error(`Invalid Date is not a valid boundary value.`);if(l(this._checks,0,e,(e,t)=>e.getTime()-t.getTime(),-1))throw Error(`Minimum must not exceed maximum.`);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:1,param:new Date(e.getTime()),issue:this.issues.TOO_RECENT}),t}},O=()=>D;var k=class e extends h{_values;_set;issues;constructor(...e){if(super(),e.length===0)throw Error(`Enum must contain at least one value.`);this._values=Object.freeze([...e]),this._set=new Set(e),this.issues={INVALID_ENUM_VALUE:{type:`leaf`,code:i.INVALID_ENUM_VALUE,expected:this._values.map(c)}}}_clone(){return new e(...this._values)}_parse(e,t,n){if(!this._set.has(e))return this.issues.INVALID_ENUM_VALUE}extract(...t){return new e(...t)}exclude(...t){let n=new Set(t),r=this._values.filter(e=>!n.has(e));return new e(...r)}};const A=(...e)=>new k(...e),j=new class e extends h{_checks=void 0;issues={INVALID_TYPE:{type:`leaf`,code:i.INVALID_TYPE,expected:`number`},TOO_SMALL:{type:`leaf`,code:i.TOO_SMALL},TOO_LARGE:{type:`leaf`,code:i.TOO_LARGE},INVALID_INTEGER:{type:`leaf`,code:i.INVALID_INTEGER},INVALID_FINITE:{type:`leaf`,code:i.INVALID_FINITE},INVALID_SAFE_INTEGER:{type:`leaf`,code:i.INVALID_SAFE_INTEGER}};_clone(){let t=new e;return t._checks=this._checks?.slice(),t}_parse(e,t,n){if(typeof e!=`number`||Number.isNaN(e))return this.issues.INVALID_TYPE;if(this._checks!==void 0){let t=this._checks;for(let n=0;n<t.length;n++){let{tag:r,param:i,issue:a}=t[n];switch(r){case 0:if(e<i)return a;break;case 1:if(e<=i)return a;break;case 2:if(e>i)return a;break;case 3:if(e>=i)return a;break;case 4:if(!Number.isInteger(e))return a;break;case 5:if(!Number.isFinite(e))return a;break;case 6:if(!Number.isSafeInteger(e))return a;break}}}}gte(e){if(Number.isNaN(e))throw Error(`NaN is not a valid boundary value.`);T(w(this._checks,2,3),e,!1);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:0,param:e,issue:this.issues.TOO_SMALL}),t}gt(e){if(Number.isNaN(e))throw Error(`NaN is not a valid boundary value.`);T(w(this._checks,2,3),e,!0);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:1,param:e,issue:this.issues.TOO_SMALL}),t}lte(e){if(Number.isNaN(e))throw Error(`NaN is not a valid boundary value.`);E(C(this._checks,0,1),e,!1);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:2,param:e,issue:this.issues.TOO_LARGE}),t}lt(e){if(Number.isNaN(e))throw Error(`NaN is not a valid boundary value.`);E(C(this._checks,0,1),e,!0);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:3,param:e,issue:this.issues.TOO_LARGE}),t}int(){let e=this._clone();return e._checks=e._checks||[],e._checks.push({tag:4,param:0,issue:this.issues.INVALID_INTEGER}),e}finite(){let e=this._clone();return e._checks=e._checks||[],e._checks.push({tag:5,param:0,issue:this.issues.INVALID_FINITE}),e}safe(){let e=this._clone();return e._checks=e._checks||[],e._checks.push({tag:6,param:0,issue:this.issues.INVALID_SAFE_INTEGER}),e}},M=()=>j;var N=class e extends h{_shape;_shapeMap;_shapeKeys;_shapeSize;_requiredKeys;_mode=`strict`;issues={INVALID_TYPE:{type:`leaf`,code:i.INVALID_TYPE,expected:`object`},UNRECOGNIZED_KEY:{type:`leaf`,code:i.UNRECOGNIZED_KEY},MISSING_VALUE:{type:`leaf`,code:i.MISSING_VALUE}};constructor(e,t=!1){if(super(),!e)throw Error(`Object must contain at least one field.`);if(Object.getOwnPropertySymbols(e).length>0)throw Error(`Object fields must use string keys.`);if(Object.keys(e).length===0)throw Error(`Object must contain at least one field.`);this._shape=e,this._shapeMap=t?new Map(Object.entries(e)):void 0,this._shapeKeys=[...Object.keys(e)],this._shapeSize=this._shapeKeys.length,this._requiredKeys=this._shapeKeys.filter(t=>!e[t]._isOptional())}_clone(){let t=new e(this._shape,this._shapeMap!==void 0);return t._mode=this._mode,t}_parse(e,t,n){if(!o(e))return this.issues.INVALID_TYPE;let i=0,c={},l,u=!1,d,f,p=this._shapeMap;if(p===void 0)for(let o in e){let d=this._shape[o];if(d?._parse){i++;let l=e[o],p=d._parse(l,t,n);if(p===void 0)continue;r(p)?(u=!0,o===`__proto__`?s(c,p.value):c[o]=p.value):f=a(f,{type:`nest`,key:o,child:p})}else this._mode!==`passthrough`&&(l||=new Set,l.add(o))}else for(let o in e){let d=p.get(o);if(d?._parse){i++;let l=e[o],p=d._parse(l,t,n);if(p===void 0)continue;r(p)?(u=!0,o===`__proto__`?s(c,p.value):c[o]=p.value):f=a(f,{type:`nest`,key:o,child:p})}else this._mode!==`passthrough`&&(l||=new Set,l.add(o))}if(i<this._shapeSize){let i=Object.getOwnPropertyNames(e).length!==Object.keys(e).length;for(let i of this._requiredKeys)if(!Object.hasOwn(e,i)){let e=this._parseMissingKey(i,t,n);if(e===void 0)continue;r(e)?(u=!0,i===`__proto__`?s(c,e.value):c[i]=e.value):f=a(f,{type:`nest`,key:i,child:e})}if(i){for(let i of this._shapeKeys)if(Object.hasOwn(e,i)&&!Object.prototype.propertyIsEnumerable.call(e,i)){d===void 0&&(d=[]),d.push(i);let o=this._shape[i]._parse(e[i],t,n);o!==void 0&&(r(o)?(u=!0,i===`__proto__`?s(c,o.value):c[i]=o.value):f=a(f,{type:`nest`,key:i,child:o}))}}}if(l&&this._mode===`strict`)for(let e of l)f=a(f,{type:`nest`,key:e,child:this.issues.UNRECOGNIZED_KEY});if(f)return f;if(l&&this._mode===`strip`){let t={};for(let n in e)l.has(n)||(u&&Object.hasOwn(c,n)?n===`__proto__`?s(t,c[n]):t[n]=c[n]:n===`__proto__`?s(t,e[n]):t[n]=e[n]);if(u)for(let n in c)Object.hasOwn(e,n)||(n===`__proto__`?s(t,c[n]):t[n]=c[n]);if(d)for(let n of d){let r=u&&Object.hasOwn(c,n)?c[n]:e[n];n===`__proto__`?s(t,r):t[n]=r}return{ok:!0,value:t}}if(u)return{ok:!0,value:{...e,...c}}}_parseMissingKey(e,t,n){let r=this._shapeMap,i=r===void 0?this._shape[e]:r.get(e);return i instanceof y?{ok:!0,value:i._getDefault()}:i._hasDefault()?i._parse(void 0,t,n):this.issues.MISSING_VALUE}get shape(){return this._shape}strip(){let e=this._clone();return e._mode=`strip`,e}strict(){let e=this._clone();return e._mode=`strict`,e}passthrough(){let e=this._clone();return e._mode=`passthrough`,e}merge(t){let n=new e({...this._shape,...t._shape},!0);return n._mode=t._mode,n}pick(...t){let n=new Set(t.map(e=>String(e))),r=new e(Object.fromEntries(Object.entries(this._shape).filter(([e])=>n.has(e))),!0);return r._mode=this._mode,r}omit(...t){let n=new Set(t.map(e=>String(e))),r=new e(Object.fromEntries(Object.entries(this._shape).filter(([e])=>!n.has(e))),!0);return r._mode=this._mode,r}partial(...t){let n=t.length===0?null:new Set(t.map(e=>String(e))),r=n===null?()=>!0:e=>n.has(e),i={};for(let[e,t]of Object.entries(this._shape))r(e)&&!t._isOptional()&&!t._hasDefault()?i[e]=t.optional():i[e]=t;let a=new e(i,!0);return a._mode=this._mode,a}required(...t){let n=t.length===0?null:new Set(t.map(e=>String(e))),r=n===null?()=>!0:e=>n.has(e),i={};for(let[e,t]of Object.entries(this._shape))r(e)?i[e]=t._unwrapOptional():i[e]=t;let a=new e(i,!0);return a._mode=this._mode,a}};const P=(...e)=>new N(...e),F=()=>/^(?:(?:[a-z\d\!\#\$\%\&'\*\-\/\=\?\^_\u0060\{\|\}\~\+]+)(?:\.(?:[a-z\d\!\#\$\%\&'\*\-\/\=\?\^_\u0060\{\|\}\~\+]+))*(?:)@(?:(?:[a-z\d](?:[a-z\d\-]*[a-z\d])?\.)+[a-z]{2,}))$/iv,I=()=>/^\p{RGI_Emoji}+$/v,L=()=>/^(?:(?:\p{AHex}{8}-\p{AHex}{4}-[1-8]\p{AHex}{3}-[89ab]\p{AHex}{3}-\p{AHex}{12})|(?:00000000-0000-0000-0000-000000000000)|(?:ffffffff-ffff-ffff-ffff-ffffffffffff))$/iv,R=()=>/^[a-z\d_-]{21}$/i,z=()=>/^(?:(?:(?:https?|ftp|wss?):\/\/(?:(?=[a-z\d\._\-]*?[a-z_\-])(?:(?=([a-z\d\._\-]+))\1))(?::(?:6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{3}|[1-5]\d{4}|\d{1,4}))?(?:(?:[\/\?\#].*)?))|(?:(?!(?:(?:https?|ftp|wss?|file):))[a-z](?:(?=([a-z\d\+\.\-]*))\2):(?!\/\/).*))$/iv,B=()=>/^(?:(?:(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29)|\d{4}-(?:(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01]))|(?:(?:0[469]|11)-(?:0[1-9]|[12]\d|30))|(?:02-(?:0[1-9]|1\d|2[0-8])))))$/v,V=(e,t,n=!0)=>RegExp(`^(?:(?:(?:[01]\\d|2[0-3])):(?:[0-5]\\d):(?:[0-5]\\d)(?:${e===void 0?`(\\.\\d+)?`:e===0?``:`\\.\\d{${String(e)}}`})(?:${t&&n?`((?:[+\\-](?:(?:[01]\\d|2[0-3])):(?:[0-5]\\d))|Z?)`:t?`((?:[+\\-](?:(?:[01]\\d|2[0-3])):(?:[0-5]\\d))|Z)`:n?`Z?`:`Z`}))$`,`v`),H=(e,t,n)=>RegExp(`^(?:(?:(?:(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29)|\\d{4}-(?:(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01]))|(?:(?:0[469]|11)-(?:0[1-9]|[12]\\d|30))|(?:02-(?:0[1-9]|1\\d|2[0-8])))))T(?:(?:(?:[01]\\d|2[0-3])):(?:[0-5]\\d):(?:[0-5]\\d)(?:${e===void 0?`(\\.\\d+)?`:e===0?``:`\\.\\d{${String(e)}}`}))(?:${t&&n?`((?:[+\\-](?:(?:[01]\\d|2[0-3])):(?:[0-5]\\d))|Z?)`:t?`((?:[+\\-](?:(?:[01]\\d|2[0-3])):(?:[0-5]\\d))|Z)`:n?`Z?`:`Z`}))$`,`v`),U=e=>RegExp(`^(?:${e===void 0?`((?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d))|(?:(?:(?:(?:\\p{AHex}{1,4}):){7}(?:(?:\\p{AHex}{1,4})|:)|(?:(?:\\p{AHex}{1,4}):){6}(?:(?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d))|:(?:\\p{AHex}{1,4})|:)|(?:(?:\\p{AHex}{1,4}):){5}(?::(?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d))|(?::(?:\\p{AHex}{1,4})){1,2}|:)|(?:(?:\\p{AHex}{1,4}):){4}(?:(?::(?:\\p{AHex}{1,4})){0,1}(?:):(?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d))|(?::(?:\\p{AHex}{1,4})){1,3}|:)|(?:(?:\\p{AHex}{1,4}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:(?:\\p{AHex}{1,4}):){3}(?:(?::(?:\\p{AHex}{1,4})){0,2}(?:):(?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d))|(?::(?:\\p{AHex}{1,4})){1,4}|:)|(?:(?:\\p{AHex}{1,4}):){2}(?:(?::(?:\\p{AHex}{1,4})){0,3}(?:):(?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d))|(?::(?:\\p{AHex}{1,4})){1,5}|:)|(?:(?:\\p{AHex}{1,4}):){1}(?:(?::(?:\\p{AHex}{1,4})){0,4}(?:):(?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d))|(?::(?:\\p{AHex}{1,4})){1,6}|:)|(?::(?:(?::(?:\\p{AHex}{1,4})){0,5}(?:):(?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d))|(?::(?:\\p{AHex}{1,4})){1,7}|:)))(?:%[\\da-z]+)?)\\/(?:(?:12[0-8]|1[01]\\d|\\d{1,2})))`})$`,`iv`),G=new class e extends h{_checks=void 0;issues={INVALID_TYPE:{type:`leaf`,code:i.INVALID_TYPE,expected:`string`},TOO_SHORT:{type:`leaf`,code:i.TOO_SHORT},TOO_LONG:{type:`leaf`,code:i.TOO_LONG},INVALID_EMAIL:{type:`leaf`,code:i.INVALID_EMAIL},INVALID_EMOJI:{type:`leaf`,code:i.INVALID_EMOJI},INVALID_UUID:{type:`leaf`,code:i.INVALID_UUID},INVALID_NANOID:{type:`leaf`,code:i.INVALID_NANOID},DOES_NOT_INCLUDE:{type:`leaf`,code:i.DOES_NOT_INCLUDE},DOES_NOT_START_WITH:{type:`leaf`,code:i.DOES_NOT_START_WITH},DOES_NOT_END_WITH:{type:`leaf`,code:i.DOES_NOT_END_WITH},INVALID_DATE_STRING:{type:`leaf`,code:i.INVALID_DATE_STRING},INVALID_TIME_STRING:{type:`leaf`,code:i.INVALID_TIME_STRING},INVALID_DATE_TIME_STRING:{type:`leaf`,code:i.INVALID_DATE_TIME_STRING},INVALID_IP_ADDRESS:{type:`leaf`,code:i.INVALID_IP_ADDRESS},INVALID_IP_ADDRESS_RANGE:{type:`leaf`,code:i.INVALID_IP_ADDRESS_RANGE},INVALID_URL:{type:`leaf`,code:i.INVALID_URL},DOES_NOT_MATCH_REGEX:{type:`leaf`,code:i.DOES_NOT_MATCH_REGEX}};_clone(){let t=new e;return t._checks=this._checks?.slice(),t}_parse(e,t,n){if(typeof e!=`string`)return this.issues.INVALID_TYPE;if(this._checks!==void 0){let t=this._checks;for(let n=0;n<t.length;n++){let r=t[n];switch(r.tag){case 0:if(e.length<r.param)return r.issue;break;case 1:if(e.length>r.param)return r.issue;break;case 2:if(r.param.lastIndex=0,!r.param.test(e))return r.issue;break;case 3:if(!e.includes(r.param))return r.issue;break;case 4:if(!e.startsWith(r.param))return r.issue;break;case 5:if(!e.endsWith(r.param))return r.issue;break;case 6:if(r.param.lastIndex=0,!r.param.test(e)&&!URL.canParse(e))return r.issue;break}}}}min(e){if(!Number.isInteger(e)||e<0)throw Error(`Length must be a non-negative integer.`);if(e>this._effectiveMaxLength())throw Error(`Minimum length must not exceed maximum length.`);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:0,param:e,issue:this.issues.TOO_SHORT}),t}max(e){if(!Number.isInteger(e)||e<0)throw Error(`Length must be a non-negative integer.`);if(e<this._effectiveMinLength())throw Error(`Minimum length must not exceed maximum length.`);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:1,param:e,issue:this.issues.TOO_LONG}),t}_effectiveMinLength(){let e=0;if(this._checks!==void 0)for(let t of this._checks)t.tag===0&&t.param>e&&(e=t.param);return e}_effectiveMaxLength(){let e=1/0;if(this._checks!==void 0)for(let t of this._checks)t.tag===1&&t.param<e&&(e=t.param);return e}length(e){if(!Number.isInteger(e)||e<0)throw Error(`Length must be a non-negative integer.`);if(e<this._effectiveMinLength()||e>this._effectiveMaxLength())throw Error(`Minimum length must not exceed maximum length.`);let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:1,param:e,issue:this.issues.TOO_LONG}),t._checks.push({tag:0,param:e,issue:this.issues.TOO_SHORT}),t}email(){let e=F(),t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:2,param:e,issue:this.issues.INVALID_EMAIL}),t}emoji(){let e=I(),t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:2,param:e,issue:this.issues.INVALID_EMOJI}),t}uuid(){let e=L(),t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:2,param:e,issue:this.issues.INVALID_UUID}),t}nanoid(){let e=R(),t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:2,param:e,issue:this.issues.INVALID_NANOID}),t}includes(e){let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:3,param:e,issue:this.issues.DOES_NOT_INCLUDE}),t}startsWith(e){let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:4,param:e,issue:this.issues.DOES_NOT_START_WITH}),t}endsWith(e){let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:5,param:e,issue:this.issues.DOES_NOT_END_WITH}),t}date(){let e=B(),t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:2,param:e,issue:this.issues.INVALID_DATE_STRING}),t}time(e={}){if(e.precision!==void 0&&(!Number.isInteger(e.precision)||e.precision<0))throw Error(`Precision must be a non-negative integer.`);let t=V(e.precision,e.offset,e.local),n=this._clone();return n._checks=n._checks||[],n._checks.push({tag:2,param:t,issue:this.issues.INVALID_TIME_STRING}),n}datetime(e={}){if(e.precision!==void 0&&(!Number.isInteger(e.precision)||e.precision<0))throw Error(`Precision must be a non-negative integer.`);let t=H(e.precision,e.offset,e.local),n=this._clone();return n._checks=n._checks||[],n._checks.push({tag:2,param:t,issue:this.issues.INVALID_DATE_TIME_STRING}),n}ip(e={}){let t=U(e.version),n=this._clone();return n._checks=n._checks||[],n._checks.push({tag:2,param:t,issue:this.issues.INVALID_IP_ADDRESS}),n}cidr(e={}){let t=W(e.version),n=this._clone();return n._checks=n._checks||[],n._checks.push({tag:2,param:t,issue:this.issues.INVALID_IP_ADDRESS_RANGE}),n}url(){let e=z(),t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:6,param:e,issue:this.issues.INVALID_URL}),t}regex(e){let t=this._clone();return t._checks=t._checks||[],t._checks.push({tag:2,param:e,issue:this.issues.DOES_NOT_MATCH_REGEX}),t}},K=()=>G,q=P({id:M(),created:O(),title:K().min(1).max(100),type:A(`jpg`,`png`),size:M(),url:K().url()}),J=P({id:M(),stars:M().gte(0).lte(5),title:K().min(1).max(100),text:K().min(1).max(1e3),images:S(q)});P({id:M(),created:O(),title:K().min(1).max(100),brand:K().min(1).max(30),description:K().min(1).max(500),price:M().gte(1).lte(1e4),discount:M().gte(1).lte(100).nullable(),quantity:M().gte(0).lte(10),tags:S(K().min(1).max(30)),images:S(q),ratings:S(J)}).safeParse({});
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser