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/compiler/Compiled (minified)Compiled (minified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/@paseri/compiler/download_compiled/minified.js
Copy to clipboardCopy to clipboard
const e={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 t(e,t){return e?{type:`join`,left:e,right:t}:t}function n(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 r=class{ok=!1;_issue;constructor(e){this._issue=e}get issue(){return this._issue}messages(e){return n(this._issue,e)}},i=class extends Error{_issue;constructor(e){super("Failed to parse. See `e.messages()` for details."),this._issue=e}messages(e){return n(this._issue,e)}};function a(e){return e.ok===!0}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}const s=new Set([`jpg`,`png`]),c=RegExp(`^(?:(?:(?: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`);function l(e){for(let t=0;t<e.length;t++){let n=e[t];if(!(typeof n==`string`&&n.length>=1&&n.length<=30))return!1}return!0}function u(e){let t=0;for(let n in e)t++;return t<=6}function d(e){for(let t=0;t<e.length;t++){let n=e[t];if(!(o(n)&&typeof n.id==`number`&&!Number.isNaN(n.id)&&n.created instanceof Date&&!Number.isNaN(n.created.getTime())&&typeof n.title==`string`&&n.title.length>=1&&n.title.length<=100&&s.has(n.type)&&typeof n.size==`number`&&!Number.isNaN(n.size)&&typeof n.url==`string`&&(c.test(n.url)||URL.canParse(n.url))&&u(n)))return!1}return!0}function f(e){let t=0;for(let n in e)t++;return t<=5}function p(e){for(let t=0;t<e.length;t++){let n=e[t];if(!(o(n)&&typeof n.id==`number`&&!Number.isNaN(n.id)&&typeof n.stars==`number`&&!Number.isNaN(n.stars)&&n.stars>=0&&n.stars<=5&&typeof n.title==`string`&&n.title.length>=1&&n.title.length<=100&&typeof n.text==`string`&&n.text.length>=1&&n.text.length<=1e3&&Array.isArray(n.images)&&d(n.images)&&f(n)))return!1}return!0}function m(n){let r;if(!o(n))r=t(r,{type:`leaf`,code:e.INVALID_TYPE,expected:`object`});else{let i,a,o=`id`in n;o&&(a=n.id,typeof a==`number`&&!Number.isNaN(a)||(i=t(i,{type:`nest`,key:`id`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`number`}})));let l,u=`created`in n;if(u)if(l=n.created,!(l instanceof Date))i=t(i,{type:`nest`,key:`created`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`Date`}});else{let n=l.getTime();Number.isNaN(n)&&(i=t(i,{type:`nest`,key:`created`,child:{type:`leaf`,code:e.INVALID_DATE}}))}let d,f=`title`in n;if(f)if(d=n.title,typeof d!=`string`)i=t(i,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`string`}});else _labelCheck97:{if(!(d.length>=1)){i=t(i,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.TOO_SHORT}});break _labelCheck97}if(!(d.length<=100)){i=t(i,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.TOO_LONG}});break _labelCheck97}}let p,m=`type`in n;m&&(p=n.type,s.has(p)||(i=t(i,{type:`nest`,key:`type`,child:{type:`leaf`,code:e.INVALID_ENUM_VALUE,expected:[`'jpg'`,`'png'`]}})));let h,g=`size`in n;g&&(h=n.size,typeof h==`number`&&!Number.isNaN(h)||(i=t(i,{type:`nest`,key:`size`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`number`}})));let _,v=`url`in n;if(v){if(_=n.url,typeof _!=`string`)i=t(i,{type:`nest`,key:`url`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`string`}});else _labelCheck104:if(!(c.test(_)||URL.canParse(_))){i=t(i,{type:`nest`,key:`url`,child:{type:`leaf`,code:e.INVALID_URL}});break _labelCheck104}}o||(i=t(i,{type:`nest`,key:`id`,child:{type:`leaf`,code:e.MISSING_VALUE}})),u||(i=t(i,{type:`nest`,key:`created`,child:{type:`leaf`,code:e.MISSING_VALUE}})),f||(i=t(i,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.MISSING_VALUE}})),m||(i=t(i,{type:`nest`,key:`type`,child:{type:`leaf`,code:e.MISSING_VALUE}})),g||(i=t(i,{type:`nest`,key:`size`,child:{type:`leaf`,code:e.MISSING_VALUE}})),v||(i=t(i,{type:`nest`,key:`url`,child:{type:`leaf`,code:e.MISSING_VALUE}}));let y=0;for(let e in n)y++;if(y!==6||!o||!u||!f||!m||!g||!v)for(let r in n)r===`id`||r===`created`||r===`title`||r===`type`||r===`size`||r===`url`||(i=t(i,{type:`nest`,key:r,child:{type:`leaf`,code:e.UNRECOGNIZED_KEY}}));i!==void 0&&(r=t(r,i))}return r}function h(n){let r;if(!o(n))r=t(r,{type:`leaf`,code:e.INVALID_TYPE,expected:`object`});else{let i,a,o=`id`in n;o&&(a=n.id,typeof a==`number`&&!Number.isNaN(a)||(i=t(i,{type:`nest`,key:`id`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`number`}})));let s,c=`stars`in n;if(c)if(s=n.stars,!(typeof s==`number`&&!Number.isNaN(s)))i=t(i,{type:`nest`,key:`stars`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`number`}});else _labelCheck122:{if(!(s>=0)){i=t(i,{type:`nest`,key:`stars`,child:{type:`leaf`,code:e.TOO_SMALL}});break _labelCheck122}if(!(s<=5)){i=t(i,{type:`nest`,key:`stars`,child:{type:`leaf`,code:e.TOO_LARGE}});break _labelCheck122}}let l,u=`title`in n;if(u)if(l=n.title,typeof l!=`string`)i=t(i,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`string`}});else _labelCheck125:{if(!(l.length>=1)){i=t(i,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.TOO_SHORT}});break _labelCheck125}if(!(l.length<=100)){i=t(i,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.TOO_LONG}});break _labelCheck125}}let d,f=`text`in n;if(f)if(d=n.text,typeof d!=`string`)i=t(i,{type:`nest`,key:`text`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`string`}});else _labelCheck128:{if(!(d.length>=1)){i=t(i,{type:`nest`,key:`text`,child:{type:`leaf`,code:e.TOO_SHORT}});break _labelCheck128}if(!(d.length<=1e3)){i=t(i,{type:`nest`,key:`text`,child:{type:`leaf`,code:e.TOO_LONG}});break _labelCheck128}}let p,h=`images`in n;if(h)if(p=n.images,!Array.isArray(p))i=t(i,{type:`nest`,key:`images`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`array`}});else{let e;for(let n=0;n<p.length;n++){let r=p[n],i=m(r);i!==void 0&&(e=t(e,{type:`nest`,key:n,child:i}))}e!==void 0&&(i=t(i,{type:`nest`,key:`images`,child:e}))}o||(i=t(i,{type:`nest`,key:`id`,child:{type:`leaf`,code:e.MISSING_VALUE}})),c||(i=t(i,{type:`nest`,key:`stars`,child:{type:`leaf`,code:e.MISSING_VALUE}})),u||(i=t(i,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.MISSING_VALUE}})),f||(i=t(i,{type:`nest`,key:`text`,child:{type:`leaf`,code:e.MISSING_VALUE}})),h||(i=t(i,{type:`nest`,key:`images`,child:{type:`leaf`,code:e.MISSING_VALUE}}));let g=0;for(let e in n)g++;if(g!==5||!o||!c||!u||!f||!h)for(let r in n)r===`id`||r===`stars`||r===`title`||r===`text`||r===`images`||(i=t(i,{type:`nest`,key:r,child:{type:`leaf`,code:e.UNRECOGNIZED_KEY}}));i!==void 0&&(r=t(r,i))}return r}function g(n,r){let i=r?.maxDepth??1e3;if(!Number.isInteger(i)||i<1)throw Error(`maxDepth must be a positive integer.`);if(!o(n))return{type:`leaf`,code:e.INVALID_TYPE,expected:`object`};let a,s,c=`id`in n;c&&(s=n.id,typeof s==`number`&&!Number.isNaN(s)||(a=t(a,{type:`nest`,key:`id`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`number`}})));let l,u=`created`in n;if(u)if(l=n.created,!(l instanceof Date))a=t(a,{type:`nest`,key:`created`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`Date`}});else{let n=l.getTime();Number.isNaN(n)&&(a=t(a,{type:`nest`,key:`created`,child:{type:`leaf`,code:e.INVALID_DATE}}))}let d,f=`title`in n;if(f)if(d=n.title,typeof d!=`string`)a=t(a,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`string`}});else _labelCheck60:{if(!(d.length>=1)){a=t(a,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.TOO_SHORT}});break _labelCheck60}if(!(d.length<=100)){a=t(a,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.TOO_LONG}});break _labelCheck60}}let p,g=`brand`in n;if(g)if(p=n.brand,typeof p!=`string`)a=t(a,{type:`nest`,key:`brand`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`string`}});else _labelCheck63:{if(!(p.length>=1)){a=t(a,{type:`nest`,key:`brand`,child:{type:`leaf`,code:e.TOO_SHORT}});break _labelCheck63}if(!(p.length<=30)){a=t(a,{type:`nest`,key:`brand`,child:{type:`leaf`,code:e.TOO_LONG}});break _labelCheck63}}let _,v=`description`in n;if(v)if(_=n.description,typeof _!=`string`)a=t(a,{type:`nest`,key:`description`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`string`}});else _labelCheck66:{if(!(_.length>=1)){a=t(a,{type:`nest`,key:`description`,child:{type:`leaf`,code:e.TOO_SHORT}});break _labelCheck66}if(!(_.length<=500)){a=t(a,{type:`nest`,key:`description`,child:{type:`leaf`,code:e.TOO_LONG}});break _labelCheck66}}let y,b=`price`in n;if(b)if(y=n.price,!(typeof y==`number`&&!Number.isNaN(y)))a=t(a,{type:`nest`,key:`price`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`number`}});else _labelCheck69:{if(!(y>=1)){a=t(a,{type:`nest`,key:`price`,child:{type:`leaf`,code:e.TOO_SMALL}});break _labelCheck69}if(!(y<=1e4)){a=t(a,{type:`nest`,key:`price`,child:{type:`leaf`,code:e.TOO_LARGE}});break _labelCheck69}}let x,S=`discount`in n;if(S&&(x=n.discount,x!==null))if(!(typeof x==`number`&&!Number.isNaN(x)))a=t(a,{type:`nest`,key:`discount`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`number`}});else _labelCheck72:{if(!(x>=1)){a=t(a,{type:`nest`,key:`discount`,child:{type:`leaf`,code:e.TOO_SMALL}});break _labelCheck72}if(!(x<=100)){a=t(a,{type:`nest`,key:`discount`,child:{type:`leaf`,code:e.TOO_LARGE}});break _labelCheck72}}let C,w=`quantity`in n;if(w)if(C=n.quantity,!(typeof C==`number`&&!Number.isNaN(C)))a=t(a,{type:`nest`,key:`quantity`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`number`}});else _labelCheck75:{if(!(C>=0)){a=t(a,{type:`nest`,key:`quantity`,child:{type:`leaf`,code:e.TOO_SMALL}});break _labelCheck75}if(!(C<=10)){a=t(a,{type:`nest`,key:`quantity`,child:{type:`leaf`,code:e.TOO_LARGE}});break _labelCheck75}}let T,E=`tags`in n;if(E)if(T=n.tags,!Array.isArray(T))a=t(a,{type:`nest`,key:`tags`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`array`}});else{let n;for(let r=0;r<T.length;r++){let i=T[r];if(typeof i!=`string`)n=t(n,{type:`nest`,key:r,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`string`}});else _labelCheck81:{if(!(i.length>=1)){n=t(n,{type:`nest`,key:r,child:{type:`leaf`,code:e.TOO_SHORT}});break _labelCheck81}if(!(i.length<=30)){n=t(n,{type:`nest`,key:r,child:{type:`leaf`,code:e.TOO_LONG}});break _labelCheck81}}}n!==void 0&&(a=t(a,{type:`nest`,key:`tags`,child:n}))}let D,O=`images`in n;if(O)if(D=n.images,!Array.isArray(D))a=t(a,{type:`nest`,key:`images`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`array`}});else{let e;for(let n=0;n<D.length;n++){let r=D[n],i=m(r);i!==void 0&&(e=t(e,{type:`nest`,key:n,child:i}))}e!==void 0&&(a=t(a,{type:`nest`,key:`images`,child:e}))}let k,A=`ratings`in n;if(A)if(k=n.ratings,!Array.isArray(k))a=t(a,{type:`nest`,key:`ratings`,child:{type:`leaf`,code:e.INVALID_TYPE,expected:`array`}});else{let e;for(let n=0;n<k.length;n++){let r=k[n],i=h(r);i!==void 0&&(e=t(e,{type:`nest`,key:n,child:i}))}e!==void 0&&(a=t(a,{type:`nest`,key:`ratings`,child:e}))}c||(a=t(a,{type:`nest`,key:`id`,child:{type:`leaf`,code:e.MISSING_VALUE}})),u||(a=t(a,{type:`nest`,key:`created`,child:{type:`leaf`,code:e.MISSING_VALUE}})),f||(a=t(a,{type:`nest`,key:`title`,child:{type:`leaf`,code:e.MISSING_VALUE}})),g||(a=t(a,{type:`nest`,key:`brand`,child:{type:`leaf`,code:e.MISSING_VALUE}})),v||(a=t(a,{type:`nest`,key:`description`,child:{type:`leaf`,code:e.MISSING_VALUE}})),b||(a=t(a,{type:`nest`,key:`price`,child:{type:`leaf`,code:e.MISSING_VALUE}})),S||(a=t(a,{type:`nest`,key:`discount`,child:{type:`leaf`,code:e.MISSING_VALUE}})),w||(a=t(a,{type:`nest`,key:`quantity`,child:{type:`leaf`,code:e.MISSING_VALUE}})),E||(a=t(a,{type:`nest`,key:`tags`,child:{type:`leaf`,code:e.MISSING_VALUE}})),O||(a=t(a,{type:`nest`,key:`images`,child:{type:`leaf`,code:e.MISSING_VALUE}})),A||(a=t(a,{type:`nest`,key:`ratings`,child:{type:`leaf`,code:e.MISSING_VALUE}}));let j=0;for(let e in n)j++;if(j!==11||!c||!u||!f||!g||!v||!b||!S||!w||!E||!O||!A)for(let r in n)r===`id`||r===`created`||r===`title`||r===`brand`||r===`description`||r===`price`||r===`discount`||r===`quantity`||r===`tags`||r===`images`||r===`ratings`||(a=t(a,{type:`nest`,key:r,child:{type:`leaf`,code:e.UNRECOGNIZED_KEY}}));if(a!==void 0)return a}function _(e,t){let n=t?.maxDepth??1e3;if(!Number.isInteger(n)||n<1)throw Error(`maxDepth must be a positive integer.`);if(!o(e))return g(e,t);let r=e.id;if(!(typeof r==`number`&&!Number.isNaN(r)))return g(e,t);let i=e.created;if(!(i instanceof Date&&!Number.isNaN(i.getTime())))return g(e,t);let a=e.title;if(!(typeof a==`string`&&a.length>=1&&a.length<=100))return g(e,t);let s=e.brand;if(!(typeof s==`string`&&s.length>=1&&s.length<=30))return g(e,t);let c=e.description;if(!(typeof c==`string`&&c.length>=1&&c.length<=500))return g(e,t);let u=e.price;if(!(typeof u==`number`&&!Number.isNaN(u)&&u>=1&&u<=1e4))return g(e,t);let f=e.discount;if(!(f===null||typeof f==`number`&&!Number.isNaN(f)&&f>=1&&f<=100))return g(e,t);let m=e.quantity;if(!(typeof m==`number`&&!Number.isNaN(m)&&m>=0&&m<=10))return g(e,t);let h=e.tags;if(!(Array.isArray(h)&&l(h)))return g(e,t);let _=e.images;if(!(Array.isArray(_)&&d(_)))return g(e,t);let v=e.ratings;if(!(Array.isArray(v)&&p(v)))return g(e,t);let y=0;for(let t in e)y++;if(y>11)return g(e,t)}function v(e,t){let n=_(e,t);return n===void 0?{ok:!0,value:e}:a(n)?n:new r(n)}function y(e,t){let n=v(e,t);if(n.ok)return n.value;throw new i(n.issue)}({"~standard":{version:1,vendor:`paseri`,validate(e,t){let n=v(e);return n.ok?{value:n.value}:{issues:n.messages(t?.libraryOptions?.locale)}}},safeParse:v,parse:y}).safeParse({});
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser