Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ajv-draft-04

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-draft-04

Ajv class for JSON Schema draft-04

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9M
decreased by-0.22%
Maintainers
1
Weekly downloads
 
Created

What is ajv-draft-04?

The ajv-draft-04 package is an extension for AJV, a popular JSON schema validator, enabling it to validate schemas written according to the JSON Schema Draft 04 specification. This package allows users to leverage AJV's fast validation capabilities while ensuring compatibility with older schema versions.

What are ajv-draft-04's main functionalities?

Validating JSON objects against a Draft 04 schema

This code demonstrates how to create a new AJV instance compatible with Draft 04 schemas, compile a schema, and validate a JSON object against it. It checks if the object meets the schema requirements (in this case, having a name as a string and an age as a number not less than 18), and prints whether the object is valid or not.

{"const Ajv = require('ajv-draft-04'); const ajv = new Ajv(); const schema = { 'type': 'object', 'properties': { 'name': { 'type': 'string' }, 'age': { 'type': 'number', 'minimum': 18 } }, 'required': ['name', 'age'] }; const validate = ajv.compile(schema); const valid = validate({ 'name': 'John Doe', 'age': 25 }); if (valid) console.log('Valid!'); else console.log('Invalid: ' + ajv.errorsText(validate.errors));"}

Other packages similar to ajv-draft-04

Keywords

FAQs

Package last updated on 19 May 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc