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
@railway-ts/pipelines/Compiled (minified)Compiled (minified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/@railway-ts/pipelines/download_compiled/minified.js
code_off
View RawView Raw
Copy to clipboardCopy to clipboard
var e = Symbol(`RESULT_BRAND`); function t(t) { return { ok: !0, value: t, [e]: `ok` }; } function n(t) { return { ok: !1, error: t, [e]: `error` }; } function r(e) { return e.ok; } function i(e) { return !e.ok; } var a = !1; function o() { return a; } function s(e, t) { let n = a; a = e; try { return t(); } finally { a = n; } } function c(e, { strict: i = !0 } = {}) { return (a, s = []) => { if (typeof a != `object` || !a) return n([{ path: s, message: `Expected an object` }]); let c = o(), l = [], u = {}; if (i !== !1) { let t = Object.keys(a).filter((t) => !Object.prototype.hasOwnProperty.call(e, t)); if (t.length > 0) { if (c) return n([{ path: [...s, t[0]], message: `Unexpected field: '${t[0]}'` }]); for (let e of t) l.push({ path: [...s, e], message: `Unexpected field: '${e}'` }); } } if (c && l.length > 0) return n(l); let d = []; for (let t in e) { if (!Object.prototype.hasOwnProperty.call(e, t)) continue; let n = e[t]; if (!n) continue; if (c && l.length > 0) break; let i = a[t], o = n(i, [...s, t]); if (o instanceof Promise) { if (c && l.length > 0) continue; d.push( o.then((e) => { r(e) ? (u[t] = e.value) : l.push(...e.error); }), ); } else if (r(o)) u[t] = o.value; else if ((l.push(...o.error), c)) break; } return d.length > 0 ? Promise.all(d).then(() => (l.length > 0 ? n(l) : t(u))) : l.length > 0 ? n(l) : t(u); }; } function l(e, t = `Field is required`) { return (r, i = []) => (r == null ? n([{ path: i, message: t }]) : e(r, i)); } function u(e = `Must be null`) { return (r, i = []) => (r === null ? t(null) : n([{ path: i, message: e }])); } function d(...e) { return (n, r = []) => { let a = t(n); for (let n of e) { if (i(a)) return a; let e = n(a.value, r); a = i(e) ? e : t(e.value); } return a; }; } function f(e, t, n = [], r) { let i = Array.isArray(n) ? n : []; return (Array.isArray(n) ? r : n)?.abortEarly ? s(!0, () => t(e, i)) : t(e, i); } function p(e = `Must be a string`) { return (r, i = []) => (typeof r == `string` ? t(r) : n([{ path: i, message: e }])); } function m(e, r = `Must be at least ${e} characters`) { return (i, a = []) => (i.length < e ? n([{ path: a, message: r }]) : t(i)); } function h(e, r = `Must be at most ${e} characters`) { return (i, a = []) => (i.length > e ? n([{ path: a, message: r }]) : t(i)); } function g(e = `Invalid URL format`) { return (r, i = []) => { try { return (new URL(r), t(r)); } catch { return n([{ path: i, message: e }]); } }; } function _(e) { return (i, a = []) => { if (!Array.isArray(i)) return n([{ path: a, message: `Expected an array` }]); let s = o(), c = [], l = Array.from({ length: i.length }), u = []; for (let [t, n] of i.entries()) { if (s && c.length > 0) break; let i = e(n, [...a, t.toString()]); if (i instanceof Promise) { if (s && c.length > 0) continue; let e = t; u.push( i.then((t) => { r(t) ? (l[e] = t.value) : c.push(...t.error); }), ); } else if (r(i)) l[t] = i.value; else if ((c.push(...i.error), s)) break; } return u.length > 0 ? Promise.all(u).then(() => (c.length > 0 ? n(c) : t(l))) : c.length > 0 ? n(c) : t(l); }; } function v(e, r = `Value must be one of: ${e.join(`, `)}`) { return d(p(`Value must be a string`), (i, a = []) => e.includes(i) ? t(i) : n([{ path: a, message: r }]), ); } function y(e = `Must be a number`) { return (r, i = []) => typeof r != `number` || Number.isNaN(r) ? n([{ path: i, message: e }]) : t(r); } function b(e, r = `Must be at least ${e}`) { return (i, a = []) => (i < e ? n([{ path: a, message: r }]) : t(i)); } function x(e, r = `Must be at most ${e}`) { return (i, a = []) => (i > e ? n([{ path: a, message: r }]) : t(i)); } function S(e = `Must be a Date object`) { return (r, i = []) => r instanceof Date ? Number.isNaN(r.getTime()) ? n([{ path: i, message: `Invalid Date` }]) : t(r) : n([{ path: i, message: e }]); } function C(e, t) { let { collectAllErrors: i = !0, errorPrefix: a } = t || {}, o = (e) => n(e.flat().map((e) => ({ path: e.path, message: a ? `${a}: ${e.message}` : e.message }))); return (t, a = []) => { if (e.length === 0) return n([{ path: a, message: `No validators provided to union` }]); let s = []; for (let n = 0; n < e.length; n++) { let c = e[n](t, a); if (c instanceof Promise) return (async () => { let l = await c; if (r(l)) return l; if ((s.push(l.error), !i)) return o(s); for (let o = n + 1; o < e.length; o++) { let n = await e[o](t, a); if (r(n)) return n; if ((s.push(n.error), !i)) break; } return o(s); })(); if (r(c)) return c; if ((s.push(c.error), !i)) break; } return o(s); }; } const w = c({ id: l(y()), created: l(S()), title: l(d(p(), m(1), h(100))), type: l(v([`jpg`, `png`])), size: l(y()), url: l(d(p(), g())), }), T = c({ id: l(y()), stars: l(d(y(), b(0), x(5))), title: l(d(p(), m(1), h(100))), text: l(d(p(), m(1), h(1e3))), images: l(_(w)), }); f( {}, c({ id: l(y()), created: l(S()), title: l(d(p(), m(1), h(100))), brand: l(d(p(), m(1), h(30))), description: l(d(p(), m(1), h(500))), price: l(d(y(), b(1), x(1e4))), discount: C([d(y(), b(1), x(100)), u()]), quantity: l(d(y(), b(0), x(10))), tags: l(_(d(p(), m(1), h(30)))), images: l(_(w)), ratings: l(_(T)), }), );
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures