Index

Functions

validateWithFile

  • validateWithFile validates a value using a schema located at the path (relative to the input directory).

    Parameters

    • obj: any
    • path: string

    Returns Promise<ValidationResult>

validateWithObject

  • 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 ValidationResult

validateWithResource

  • validateWithResource(obj: any, path: string, moduleRef: string): Promise<ValidationResult>
  • 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<ValidationResult>