jsonschema
- Version 1.5.0
- Published
- 83.5 kB
- No dependencies
- MIT license
Install
npm i jsonschemayarn add jsonschemapnpm add jsonschemaOverview
A fast and easy to use JSON Schema validator
Index
Functions
Classes
Interfaces
Schema
- 'enum'
- $id
- $ref
- $schema
- additionalItems
- additionalProperties
- allOf
- anyOf
- const
- contains
- default
- definitions
- dependencies
- description
- else
- examples
- exclusiveMaximum
- exclusiveMinimum
- format
- id
- if
- items
- maximum
- maxItems
- maxLength
- maxProperties
- minimum
- minItems
- minLength
- minProperties
- multipleOf
- not
- oneOf
- pattern
- patternProperties
- properties
- propertyNames
- required
- then
- title
- type
- uniqueItems
Functions
function validate
validate: (instance: any, schema: any, options?: Options) => ValidatorResult;Classes
class SchemaError
class SchemaError extends Error {}constructor
constructor(msg: string, schema: Schema);property message
message: string;property schema
schema: Schema;class ValidationError
class ValidationError {}constructor
constructor( message?: string, instance?: any, schema?: Schema, propertyPath?: any, name?: string, argument?: any);property argument
argument: any;property instance
instance: any;property message
message: string;property name
name: string;property path
path: (string | number)[];property property
property: string;property schema
schema: string | Schema;property stack
stack: string;method toString
toString: () => string;class Validator
class Validator {}constructor
constructor();property attributes
attributes: { [property: string]: CustomProperty };property customFormats
customFormats: { [formatName: string]: CustomFormat };property schemas
schemas: { [id: string]: Schema };property unresolvedRefs
unresolvedRefs: string[];method addSchema
addSchema: (schema?: Schema, uri?: string) => Schema | void;method validate
validate: ( instance: any, schema: Schema, options?: Options, ctx?: SchemaContext) => ValidatorResult;class ValidatorResult
class ValidatorResult {}constructor
constructor(instance: any, schema: Schema, options: Options, ctx: SchemaContext);property disableFormat
disableFormat: boolean;property errors
errors: ValidationError[];property instance
instance: any;property propertyPath
propertyPath: string;property schema
schema: Schema;property throwError
throwError: boolean;property valid
valid: boolean;method addError
addError: (detail: string | ErrorDetail) => ValidationError;method toString
toString: () => string;class ValidatorResultError
class ValidatorResultError extends Error {}Interfaces
interface CustomFormat
interface CustomFormat {}call signature
(input: any): boolean;interface CustomProperty
interface CustomProperty {}call signature
(instance: any, schema: Schema, options: Options, ctx: SchemaContext): | string | ValidatorResult;interface ErrorDetail
interface ErrorDetail {}interface Options
interface Options {}property allowUnknownAttributes
allowUnknownAttributes?: boolean;property base
base?: string;property nestedErrors
nestedErrors?: boolean;property preValidateProperty
preValidateProperty?: PreValidatePropertyFunction;property required
required?: boolean;property rewrite
rewrite?: RewriteFunction;property skipAttributes
skipAttributes?: string[];property throwAll
throwAll?: boolean;property throwError
throwError?: boolean;property throwFirst
throwFirst?: boolean;interface PreValidatePropertyFunction
interface PreValidatePropertyFunction {}call signature
( instance: any, key: string, schema: Schema, options: Options, ctx: SchemaContext): any;interface RewriteFunction
interface RewriteFunction {}call signature
(instance: any, schema: Schema, options: Options, ctx: SchemaContext): any;interface Schema
interface Schema {}property 'enum'
enum?: any[];property $id
$id?: string;property $ref
$ref?: string;property $schema
$schema?: string;property additionalItems
additionalItems?: boolean | Schema;property additionalProperties
additionalProperties?: boolean | Schema;property allOf
allOf?: Schema[];property anyOf
anyOf?: Schema[];property const
const?: any;property contains
contains?: Schema;property default
default?: any;property definitions
definitions?: { [name: string]: Schema;};property dependencies
dependencies?: { [name: string]: Schema | string[];};property description
description?: string;property else
else?: Schema;property examples
examples?: any[];property exclusiveMaximum
exclusiveMaximum?: number | boolean;property exclusiveMinimum
exclusiveMinimum?: number | boolean;property format
format?: string;property id
id?: string;property if
if?: Schema;property items
items?: Schema | Schema[];property maximum
maximum?: number;property maxItems
maxItems?: number;property maxLength
maxLength?: number;property maxProperties
maxProperties?: number;property minimum
minimum?: number;property minItems
minItems?: number;property minLength
minLength?: number;property minProperties
minProperties?: number;property multipleOf
multipleOf?: number;property not
not?: Schema;property oneOf
oneOf?: Schema[];property pattern
pattern?: string | RegExp;property patternProperties
patternProperties?: { [name: string]: Schema;};property properties
properties?: { [name: string]: Schema;};property propertyNames
propertyNames?: boolean | Schema;property required
required?: string[] | boolean;property then
then?: Schema;property title
title?: string;property type
type?: string | string[];property uniqueItems
uniqueItems?: boolean;interface SchemaContext
interface SchemaContext {}Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (6)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/jsonschema.
- Markdown[](https://www.jsdocs.io/package/jsonschema)
- HTML<a href="https://www.jsdocs.io/package/jsonschema"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3832 ms. - Missing or incorrect documentation? Open an issue for this package.
