Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 685 Bytes

README.md

File metadata and controls

43 lines (29 loc) · 685 Bytes

Transforms a JSON Schema to a type tcomb type.

API

transform(schema: JSONSchema): Type

Example

var transform = require('tcomb-json-schema');

var TcombType = transform({
  "type": "string",
  "enum": ["Street", "Avenue", "Boulevard"]
});

registerFormat(format: string, predicate: (x: any) => boolean): void

Registers a new format.

Example

function isEmail(x) {
  return /(.)+@(.)+/.test(x);
}

transform.registerFormat('email', isEmail);

var TcombType = transform({
  "type": "string",
  "format": 'email'
});

resetFormats(): void

Removes all registered formats.

transform.resetFormats();