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

@c8/joi-validator-promised

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@c8/joi-validator-promised

A wrapper around Joi `validate` method which provides support for promises

  • 1.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
5
Weekly downloads
 
Created
Source

Validator

A wrapper around Joi validate method which provides support for promises

Example

'use strict'

const Validator = require('@c8/joi-validator-promised')

const opts = {
 abortEarly: true
}
const validator = new Validator(opts)

const joiSchema = {
     id: Joi.number().min(1),
     name: Joi.string()
}

const data = {
 id: 2,
 name: 'C8 Management'
}

// Using the promise
validator.validate(data, joiSchema).then((result) => {
 //do something
})

// Validate Synchronously i.e. with the standard Joi validate method
let result = validator.validateSync(data, joiSchema)

//If there is no error
if (!result) {
// Do something
}

As this package is simply a wrapper around Joi validate method, the opts object that is passed to the constructor supports all Joi options

Keywords

FAQs

Package last updated on 26 Apr 2016

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