1.0.0-alpha.1 • Published 6 years ago

@shapeshift/core v1.0.0-alpha.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Shapeshift Core · GitHub license Build Stats Coverage Status

Greenkeeper badge Dependency Status devDependency Status

The core JSON Schema and UI Schema parser.

Contains iterators and validators for traversing and verifying json data. This library can be used for any Javscript project, and UI Schema is purely optional. This library can also be used as a simple validation library for any javscript data.

You do not need to install this if you are using one of the form components such as vue-shapeshift or the shapeshift-server.

Installation

npm i --save @shapeshift/core

Usage

Iterate through properties of an JSON Schema object

shapeshift(schema, uiSchema).forEach(ss => {
    /// Child Property
    ss.schema()
})

Validate some data

validate string for length and pattern.

import { Validators } from '@shapeshift/core';
Validators.validate({
    type: 'string',
    minLength: 2,
    maxLength: 5,
    pattern: '^12345$'
}, '12345')

validate number for min max

import { Validators } from '@shapeshift/core';
Validators.validate({
    type: 'number',
    minimum: 2,
    maximum: 5,
}, 4.5)