Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "src/validator"

Index

Variables

Const trace

trace: string[] = []

Functions

getErrorMessage

  • getErrorMessage(schema: any, value: any): string

getNoSchemaErrorMessage

  • getNoSchemaErrorMessage(value: any): string

getType

  • getType(value: any): string

ngValidate

  • ngValidate(value: any, schema: any, options: IOptions): String | null
  • ngValidate - validate json object aganist schema defined

    Parameters

    • value: any

      json object

    • schema: any

      schema definition

    • options: IOptions

      Ioption config object

    Returns String | null

    string | null - if any schema fails it will return string otherwise null.

validate

  • validate(value: any, schema: any, options?: IOptions): Error | null
  • validate - will compare json object and defined schema

    Parameters

    • value: any

      json object

    • schema: any

      schema definition

    • Optional options: IOptions

    Returns Error | null

    Error | null - if value aganist schema fails then return Error otherwise null.

    
    const { validate } = require('@vasuvanka/json-validator')
    const jsonValue = { name : "hello world" };
    const jsonSchema = { name: { type : String } };
    const error = validate(json,jsonSchema, {allowUnkown:false})
    if(error){
     console.log(`Got error : ${error.message}`)
    }
    

Object literals

Const validatorConfig

validatorConfig: object

allowUnknown

allowUnknown: true = true

Generated using TypeDoc