Index

Type aliases

Result

Result: "ok" | ValidationError[]

Functions

validateWithFile

  • validateWithFile(obj: any, path: string): Promise<Result>
  • validateWithFile validates a value using a schema located at the path (relative to the input directory).

    Parameters

    • obj: any
    • path: string

    Returns Promise<Result>

validateWithObject

  • validateWithObject(obj: any, schema: Record<string, any>): Result
  • validateWithObject validates a value using a JSON schema supplied as object.

    const result = validateWithObject(5, { type: 'number' });

    Parameters

    • obj: any
    • schema: Record<string, any>

    Returns Result

validateWithResource

  • validateWithResource(obj: any, path: string, moduleRef: string): Promise<Result>
  • validateWithResource validates a value using a schema location at the given path relative to the module represented by moduleRef; this is intended to be used by wrapping it in @jkcfg/std/resource#withModuleRef.

    import { withModuleRef } from '@jkcfg/std/resource';
    
    export function validate(value) {
      return withModuleRef(ref => validateWithSchema(value, 'schema.json', ref));
    }

    Parameters

    • obj: any
    • path: string
    • moduleRef: string

    Returns Promise<Result>