Socket
Book a DemoInstallSign in
Socket

@pipedrive/joi-schema

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pipedrive/joi-schema

Schema class to use with Joi validation - provides use cases for database records with different create/update strategies

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
2
Weekly downloads
 
Created
Source

joi-schema

Schema class to use with Joi validation - provides use cases for database records with different create/update strategies

Example usage

const Schema = require('@pipedrive/joi-schema');
const Joi = require('@hapi/joi');

const validatePostHelloCouchDb = new Schema({
    dataSchema:{
        _id: Joi.string().required(),
        _rev: Joi.string().required(),
        hello: Joi.string().allow('').optional(),
        goodbye: Joi.string().allow('').optional(),
    },
    createIgnoreKeys: ['_id', '_rev'], // keys to be stripped on getCreateData() call
    updateIgnoreKeys: ['_id'], // keys to be stripped on getUpdateData() call
    bulkUpdateIgnoreKeys: [], // keys to be stripped on getBulkUpdateData() call
    xor: ['hello', 'goodbye'] // validation checks that one and only one of the xor keys is present
});

const validatedData = await validatePostHelloCouchDb.getCreateData({
        _id: '123',
        _rev: '321',
        hello: 'Hello World',
        nonsense: 'Foo',
});
console.log(JSON.stringify(validatedData));
//{hello:  'Hello World'}

Keywords

joi

FAQs

Package last updated on 31 May 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.