Home Reference Source
import {Model} from 'datamatic/src/Model/index.js'
public class | source

Model

RxVo Model Entry-point

Static Method Summary

Static Public Methods
public static

fromJSON(json: string | json, options: object): Model

Creates new PropertiesModel from JSON data

Constructor Summary

Public Constructor
public

constructor(schemas: json, options: object)

Member Summary

Public Members
public get

errors: error[] | null: *

Getter for Ajv validation error messages

public get

Returns true if object is frozen

public get

model: object | array: *

Getter for root Model

public set

model(value: object | array)

Setter for root Model value

public get

schema: any: *

Getter for document's JSON-Schema

Method Summary

Public Methods
public

addSchema(schema: *): boolean

Adds Schema to Validator instance

public

Freezes document object

public

getModelsInPath(to: *): Array[] | Object[]

Retrieves all Models at given path

public

getPath(to: *): Object | Array

public

getSchemaForKey(id: *): *

returns schema with given id

public

getSchemaForPath(path: *): any

Retrieves JSON-Schema element for given Path

public

pipeline(pipesOrSchemas: *): Pipe

public

subscribe(observer: *): Observable

Subscribes observer to root Model

public

subscribeTo(path: *, observer: *): Observable

Subscribes observer to Model at path

public

toJSON(): *

Implements toJSON

public

Implements toString

public

useSchema(id: *)

Selects schema to validate against (advanced option, use wisely)

public

validate(path: *, value: *): * | void | RegExpExecArray

Validates data against named schema

Static Public Methods

public static fromJSON(json: string | json, options: object): Model source

Creates new PropertiesModel from JSON data

Params:

NameTypeAttributeDescription
json string | json
  • JSON Object or String
options object

Model options object

Return:

Model

Public Constructors

public constructor(schemas: json, options: object) source

Params:

NameTypeAttributeDescription
schemas json
options object

Public Members

public get errors: error[] | null: * source

Getter for Ajv validation error messages

Return:

error[] | null

public get isFrozen: boolean: * source

Returns true if object is frozen

Return:

boolean

public get model: object | array: * source

Getter for root Model

Return:

object | array

public set model(value: object | array) source

Setter for root Model value

public get schema: any: * source

Getter for document's JSON-Schema

Return:

any

Public Methods

public addSchema(schema: *): boolean source

Adds Schema to Validator instance

Params:

NameTypeAttributeDescription
schema *

Return:

boolean

public freeze(): Model source

Freezes document object

Return:

Model

public getModelsInPath(to: *): Array[] | Object[] source

Retrieves all Models at given path

Params:

NameTypeAttributeDescription
to *

Return:

Array[] | Object[]

public getPath(to: *): Object | Array source

Params:

NameTypeAttributeDescription
to *

Return:

Object | Array

public getSchemaForKey(id: *): * source

returns schema with given id

Params:

NameTypeAttributeDescription
id *

Return:

*

public getSchemaForPath(path: *): any source

Retrieves JSON-Schema element for given Path

Params:

NameTypeAttributeDescription
path *

Return:

any

public pipeline(pipesOrSchemas: *): Pipe source

Params:

NameTypeAttributeDescription
pipesOrSchemas *

Return:

Pipe

public subscribe(observer: *): Observable source

Subscribes observer to root Model

Params:

NameTypeAttributeDescription
observer *

Return:

Observable

public subscribeTo(path: *, observer: *): Observable source

Subscribes observer to Model at path

Params:

NameTypeAttributeDescription
path *
observer *

Return:

Observable

public toJSON(): * source

Implements toJSON

Return:

*

public toString(): string source

Implements toString

Return:

string

public useSchema(id: *) source

Selects schema to validate against (advanced option, use wisely)

Params:

NameTypeAttributeDescription
id *

public validate(path: *, value: *): * | void | RegExpExecArray source

Validates data against named schema

Params:

NameTypeAttributeDescription
path *
value *

Return:

* | void | RegExpExecArray