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

  • JSON Schema

    • data_object
      Schema to JSON
    • code
      JSON to Schema
    • verified
      Compliance

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
valibot/Compiled (minified)Compiled (minified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures
schemas/libraries/valibot/download_compiled/index/minified.js
code
View FormattedView Formatted
Copy to clipboardCopy to clipboard
const e={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};/* @__NO_SIDE_EFFECTS__ */ function t(t){return t?{lang:t?.lang??void 0,message:t?.message,abortEarly:t?.abortEarly??void 0,abortPipeEarly:t?.abortPipeEarly??void 0}:e}/* @__NO_SIDE_EFFECTS__ */ function n(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function r(e,t,r,i,a){let o=a&&`input`in a?a.input:r.value,s=a?.expected??e.expects??null,c=a?.received??/* @__PURE__ */ n(o),l={kind:e.kind,type:e.type,input:o,expected:s,received:c,message:`Invalid ${t}: ${s?`Expected ${s} but r`:`R`}eceived ${c}`,requirement:e.requirement,path:a?.path,issues:a?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},u=e.kind===`schema`,d=a?.message??e.message??(e.reference,l.lang,void 0)??(u?(l.lang,void 0):null)??i.message??(l.lang,void 0);d!==void 0&&(l.message=typeof d==`function`?d(l):d),u&&(r.typed=!1),r.issues?r.issues.push(l):r.issues=[l]}/* @__NO_SIDE_EFFECTS__ */ function i(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}function a(e){return e[`~standard`]={version:1,vendor:`valibot`,validate:n=>e[`~run`]({value:n},/* @__PURE__ */ t())},e}var o=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};/* @__NO_SIDE_EFFECTS__ */ function s(e,t){return{kind:`validation`,type:`max_length`,reference:s,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&r(this,`length`,e,t,{received:`${e.value.length}`}),e}}}/* @__NO_SIDE_EFFECTS__ */ function c(e,t){return{kind:`validation`,type:`max_value`,reference:c,async:!1,expects:`<=${e instanceof Date?e.toJSON():/* @__PURE__ */ n(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&r(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():/* @__PURE__ */ n(e.value)}),e}}}/* @__NO_SIDE_EFFECTS__ */ function l(e,t){return{kind:`validation`,type:`min_length`,reference:l,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&r(this,`length`,e,t,{received:`${e.value.length}`}),e}}}/* @__NO_SIDE_EFFECTS__ */ function u(e,t){return{kind:`validation`,type:`min_value`,reference:u,async:!1,expects:`>=${e instanceof Date?e.toJSON():/* @__PURE__ */ n(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&r(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():/* @__PURE__ */ n(e.value)}),e}}}/* @__NO_SIDE_EFFECTS__ */ function d(e){return{kind:`validation`,type:`url`,reference:d,async:!1,expects:null,requirement(e){try{return URL.canParse?URL.canParse(e):(new URL(e),!0)}catch{return!1}},message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&r(this,`URL`,e,t),e}}}/* @__NO_SIDE_EFFECTS__ */ function f(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}/* @__NO_SIDE_EFFECTS__ */ function p(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}/* @__NO_SIDE_EFFECTS__ */ function m(e,t){return a({kind:`schema`,type:`array`,reference:m,expects:`Array`,async:!1,item:e,message:t,"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else r(this,`type`,e,t);return e}})}/* @__NO_SIDE_EFFECTS__ */ function h(e){return a({kind:`schema`,type:`date`,reference:h,expects:`Date`,async:!1,message:e,"~run"(e,t){return e.value instanceof Date?isNaN(e.value)?r(this,`type`,e,t,{received:`"Invalid Date"`}):e.typed=!0:r(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */ function g(e,t){return a({kind:`schema`,type:`nullable`,reference:g,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,"~run"(e,t){return e.value===null&&(this.default!==void 0&&(e.value=/* @__PURE__ */ p(this,e,t)),e.value===null)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}})}/* @__NO_SIDE_EFFECTS__ */ function _(e){return a({kind:`schema`,type:`number`,reference:_,expects:`number`,async:!1,message:e,"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:r(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */ function v(e,t){return a({kind:`schema`,type:`object`,reference:v,expects:`Object`,async:!1,entries:e,message:t,"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let i in this.entries){let a=this.entries[i];if(i in n||(a.type===`exact_optional`||a.type===`optional`||a.type===`nullish`)&&a.default!==void 0){let r=i in n?n[i]:/* @__PURE__ */ p(a),o=a[`~run`]({value:r},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:i,value:r};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[i]=o.value}else if(a.fallback!==void 0)e.value[i]=/* @__PURE__ */ f(a);else if(a.type!==`exact_optional`&&a.type!==`optional`&&a.type!==`nullish`&&(r(this,`key`,e,t,{input:void 0,expected:`"${i}"`,path:[{type:`object`,origin:`key`,input:n,key:i,value:n[i]}]}),t.abortEarly))break}}else r(this,`type`,e,t);return e}})}/* @__NO_SIDE_EFFECTS__ */ function y(e,t){return a({kind:`schema`,type:`picklist`,reference:y,expects:/* @__PURE__ */ i(e.map(n),`|`),async:!1,options:e,message:t,"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:r(this,`type`,e,t),e}})}/* @__NO_SIDE_EFFECTS__ */ function b(e){return a({kind:`schema`,type:`string`,reference:b,expects:`string`,async:!1,message:e,"~run"(e,t){return typeof e.value==`string`?e.typed=!0:r(this,`type`,e,t),e}})}function x(e,n,r){let i=e[`~run`]({value:n},/* @__PURE__ */ t(r));if(i.issues)throw new o(i.issues);return i.value}/* @__NO_SIDE_EFFECTS__ */ function S(...e){return a({...e[0],pipe:e,"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}})}const C=/* @__PURE__ */ v({id:/* @__PURE__ */ _(),created:/* @__PURE__ */ h(),title:/* @__PURE__ */ S(/* @__PURE__ */ b(),/* @__PURE__ */ l(1),/* @__PURE__ */ s(100)),type:/* @__PURE__ */ y([`jpg`,`png`]),size:/* @__PURE__ */ _(),url:/* @__PURE__ */ S(/* @__PURE__ */ b(),/* @__PURE__ */ d())});x(/* @__PURE__ */ v({id:/* @__PURE__ */ _(),created:/* @__PURE__ */ h(),title:/* @__PURE__ */ S(/* @__PURE__ */ b(),/* @__PURE__ */ l(1),/* @__PURE__ */ s(100)),brand:/* @__PURE__ */ S(/* @__PURE__ */ b(),/* @__PURE__ */ l(1),/* @__PURE__ */ s(30)),description:/* @__PURE__ */ S(/* @__PURE__ */ b(),/* @__PURE__ */ l(1),/* @__PURE__ */ s(500)),price:/* @__PURE__ */ S(/* @__PURE__ */ _(),/* @__PURE__ */ u(1),/* @__PURE__ */ c(1e4)),discount:/* @__PURE__ */ g(/* @__PURE__ */ S(/* @__PURE__ */ _(),/* @__PURE__ */ u(1),/* @__PURE__ */ c(100))),quantity:/* @__PURE__ */ S(/* @__PURE__ */ _(),/* @__PURE__ */ u(0),/* @__PURE__ */ c(10)),tags:/* @__PURE__ */ m(/* @__PURE__ */ S(/* @__PURE__ */ b(),/* @__PURE__ */ l(1),/* @__PURE__ */ s(30))),images:/* @__PURE__ */ m(C),ratings:/* @__PURE__ */ m(/* @__PURE__ */ v({id:/* @__PURE__ */ _(),stars:/* @__PURE__ */ S(/* @__PURE__ */ _(),/* @__PURE__ */ u(1),/* @__PURE__ */ c(5)),title:/* @__PURE__ */ S(/* @__PURE__ */ b(),/* @__PURE__ */ l(1),/* @__PURE__ */ s(100)),text:/* @__PURE__ */ S(/* @__PURE__ */ b(),/* @__PURE__ */ l(1),/* @__PURE__ */ s(1e3)),images:/* @__PURE__ */ m(C)}))}),{});