Options
All
  • Public
  • Public/Protected
  • All
Menu

Module properties

Index

Functions

compare

  • compare(objectL: any | undefined, objectR: any | undefined, tracker?: ChangeLookup, path?: string): boolean
  • Deep comparison of two objects. It returns whether or not changes have been found (returns true) or objects seem to be equal w.r.t. to their property structure and respective values (returns false). All changes that are found will be passed to the alteration lookup.

    Parameters

    • objectL: any | undefined

      Left operand for deep comparison.

    • objectR: any | undefined

      Right operand for deep comparison.

    • Optional tracker: ChangeLookup
    • Default value path: string = ""

    Returns boolean

    • False iff both objects are equal w.r.t. structure and values. True otherwise.

complement

  • complement(instance: any | undefined, schema: any): void
  • Complements default values for all (nested) properties and array's of objects of a given object (POJO/JSON). ` const schema: any = { type: 'object', properties: { foo: { type: 'object', properties: { bar: { type: 'string', default: 'moep' }, baz: { type: 'string' } } } } };

    const object: any = { }; JsonSchema.complement(object, schema); console.log(object.foo.bar); // should exist and output 'moep' `

    Parameters

    • instance: any | undefined

      Object to complement default values for.

    • schema: any

      Schema used for validation.

    Returns void

validate

  • validate(instance: any, schema: object, references?: Array<[any, string]>): boolean
  • Validates if an object (POJO/JSON) adheres to a specific structure using a JSON schema.

    Parameters

    • instance: any

      Object to validate.

    • schema: object

      JSON schema used for validation.

    • Optional references: Array<[any, string]>

      Schema references for types etc.

    Returns boolean

    • True iff the provided instance in valid according to the schema.