MCPcopy Create free account
hub / github.com/arktypeio/arktype / Validator

Class Validator

ark/type/runtime.ts:243–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243export class Validator {
244 declare meta: ArkEnv.meta
245 declare allows: (data: unknown) => boolean
246 declare assert: (data: unknown, pipedFromCtx?: Traversal) => unknown
247 declare "~standard": StandardSchemaV1.Props
248 declare withContext: (context: ArkEnv.context) => ContextualTarget
249 // a member the build bakes is the validator's own. One it doesn't reads
250 // undefined, and under the "development" condition throws with the fix
251 declare expression: string
252 declare description: string
253 declare json: JsonStructure
254 declare toJSON: () => JsonStructure
255 declare toJsonSchema: () => JsonSchema
256
257 traverse(
258 data: unknown,
259 pipedFromCtx?: Traversal
260 ): ArkErrors | {} | null | undefined {
261 return this(data, pipedFromCtx, null) as never
262 }
263
264 from(input: unknown): unknown {
265 return this.assert(input)
266 }
267
268 // a build without the expression member has none to print, and one whose
269 // validators all lack it ships no read of it
270 toString(): string {
271 return holdsExpression && this.expression !== undefined ?
272 `Type<${this.expression}>`
273 : "Type"
274 }
275}
276
277const getOwnPropertyDescriptors = /* @__PURE__ */ (() =>
278 Object.getOwnPropertyDescriptors)()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected