New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

chained-schema

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chained-schema

Concise JSON Schema type builders.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

chained-schema

Concise JSON Schema type builders.

Install

npm install chained-schema

Usage

import { object, array, number, boolean, string } from 'chained-schema';

const phoneNumber = string.pattern(/\(?\d\d\d\)?-?\d\d\d-?\d\d\d\d/);
const user = object
  .required('firstName', 'lastName')
  .props({
    firstName: string,
    lastName: string,
    email: string.nullable,
    phoneNumber: phoneNumber.nullable,
    password: string.default('secret').minLength(5),
  });

API

Properties that require inputs are called as functions. Properties that don't require inputs are just chained as getters.

For example number.maximum takes an argument, but number.nullable doesn't, so it's a getter instead of a method.

number.minimum(0).nullable.maximum(10)

array

items(items) additionalItems(additionalItems) get uniqueItems

object

props(p) properties(properties) dependencies(dependencies) patternProperties(patternProperties) additionalProperties(additionalProperties) propertyNames(propertyNames) minProperties(minProperties) maxProperties(maxProperties)

string

minLength(minLength) maxLength(maxLength) format(format) pattern(regex)

number

minimum(minimum) maximum(maximum) exclusiveMinimum(exclusiveMinimum) exclusiveMaximum(exclusiveMaximum) multipleOf(multipleOf)

integer

Same as number.

boolean

No custom boolean options.

nill (null)

No custom null options.

Combining Schemas

allOf

anyOf

oneOf

not

FAQs

Package last updated on 20 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts