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

validatejsoncharacters

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

validatejsoncharacters

A basic library to validate special characters in an jsonobject

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

validatejsoncharacters

Validates the characters of json object which matches with provided pattern

Install

npm install validatejsoncharacters

Import

const validateJsonCharacters = require('validatejsoncharacters');

Usage

Use Case 1

const jsonobject = {
            name: 'John',
            age: '12'
        };
const pattern = /^[a-zA-Z0-9_]*$/;
console.log(validateJsonCharacters(jsonobject,pattern)); // []

Use Case 2

const jsonobject = {
    name: 'John,s',
    age: '12'
};
const pattern = /^[a-zA-Z0-9_]*$/;
console.log(validateJsonCharacters(jsonobject,pattern)); // [ { id: 'name', value: 'John,s' } ]

Use Case 3

const jsonobject = {
    name: 'John,s',
    age: '12'
};
const pattern = /^[a-zA-Z0-9_]*$/;
const ignoreKeys = ['name'];
console.log(validateJsonCharacters(jsonobject, pattern, ignoreKeys)); // []

API

validateJsonCharacters(jsonObject, pattern, ignoreKeys)

  • {jsonObject} object - json object which needs to be validated

  • {pattern} regex - regex pattern for validation

  • {ignoreKeys} string[] - list of keys to be ignored while validation

Keywords

validatejson

FAQs

Package last updated on 13 Jun 2020

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