JSPM

myjson-rules

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q22499F
  • License MIT

Library that will allow the validation of objects

Package Exports

  • myjson-rules

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (myjson-rules) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

My JSON Rules

Instagram @chrisbradley.ig

npm build

Set of methods that takes in the column name and test the rule

Available Methods

  • isNullRule
  • isNotNullRule
  • isCompareRule

This package will allow you to check an objects key:value and apply a rule to is based of the param name.

Quickstart

'use strict';

const jsonRules = require('myjson-rules');

Object.prototype.isNull = jsonRules.isNullRule;
Object.prototype.isNotNull = jsonRules.isNotNullRule;
Object.prototype.isCompare = jsonRules.isCompareRule;

const user = {
    'Name': 'Chris',
    'Age': 21,
    'Vender': 'Tree',
    'Age Restriction': 'null',
    'Age Limit': 18
}

jsonRules.setNull('null'); // Defualts to NULL (String Type) if not set

console.log(user.isNotNull('Name'), user.isCompare('Age', 'Age Limit', '>'))

.isNull()

Attach this method to an object then pass in the column name you want to test.

// Access using 
Object.prototype.isNull = jsonRules.isNullRule;

const user = {
    'Name': 'Chris',
    'Age': 21,
    'Vender': 'Tree',
    'Age Restriction': 'NULL'
}

user.isNull('Age Restriction') // Output = true

.isNotNull()

Attach this method to an object then pass in the column name you want to test.

// Access using 
Object.prototype.isNotNull = jsonRules.isNotNullRule;

const user = {
    'Name': 'Chris',
    'Age': 21,
    'Vender': 'Tree',
    'Age Restriction': 'NULL'
}

user.isNotNull('Name') // Output = true

.isCompare()

Attach this method to an object then pass in the column name you want to test.

// Access using 
Object.prototype.isCompare = jsonRules.isCompareRule;

const user = {
    'Name': 'Chris',
    'Age': 21,
    'Vender': 'Tree',
    'Age Restriction': 'NULL',
    'Age Limit': 18
}

user.isCompare('Age', 'Age Limit', '>') // Output = true