1.0.1 • Published 6 years ago
myjson-rules v1.0.1
Instagram @chrisbradley.ig
Set of methods that takes in the column name and test the rule
Available Methods
This package will allow you to check an objects key:value and apply a rule to is based of the param name.
'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()
// 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()
// Access using 
Object.prototype.isNotNull = jsonRules.isNotNullRule;
const user = {
    'Name': 'Chris',
    'Age': 21,
    'Vender': 'Tree',
    'Age Restriction': 'NULL'
}
user.isNotNull('Name') // Output = true.isCompare()
// 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