项目作者: shapeshiftjs

项目描述 :
JSON Schema parsers, iterators and validators
高级语言: TypeScript
项目地址: git://github.com/shapeshiftjs/shapeshift-core.git
创建时间: 2017-12-16T18:05:29Z
项目社区:https://github.com/shapeshiftjs/shapeshift-core

开源协议:MIT License

下载


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

  1. npm i --save @shapeshift/core

Usage

Iterate through properties of an JSON Schema object

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

Validate some data

validate string for length and pattern.

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

validate number for min max

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