npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brij-spec

v0.0.5

Published

Business Rules in JSON

Downloads

6

Readme

brij-spec

Build Status Coverage Status

Business Rules in JSON. A standard, specification and schema.

We are currently in 0.x.x versioning: some core changes are still being pushed out. A version 1.0.0 will be released following best practices when identified as final.

Specification Basics

A BRIJ compliant file is a JSON document that contains an array that is a list of objects for each of your rule definitions. In the simplest form, a BRIJ compliant document looks like this:

[
  {
    "rule": {
      "condition": "email_address",
      "property": "user.email"
    }
  }
]

Each rule object in the array is defined by the following main properties:

  • id: optional
  • description: optional
  • rule: required
    • property: required
    • condition: required
  • actions: optional

Unless custom actions are defined, the engine should simply evaluate the defined rule as boolean true or false.

Defining a Rule

Valid Conditions

Custom function call
  • call
  • function
Formatting
  • email_address
  • zipcode
  • yyyy_mm_dd_hh_mm_ss
  • yyyy_mm_dd_hh_mm
  • yyyy_mm_dd
  • mm_dd_yyyy
  • yyyy
  • hh_mm
  • hh_mm_ss
  • matches_regex
  • value
Value Comparison
Numeric
  • is_integer
  • is_float
  • equal
  • value
  • equal_property
  • value
  • not_equal
  • value
  • not_equal_property
  • value
  • greater_than
  • value
  • greater_than_property
  • value
  • less_than
  • value
  • less_than_property
  • value
  • greater_than_or_equal
  • value
  • greater_than_or_equal_property
  • value
  • less_than_or_equal
  • value
  • less_than_or_equal_property
  • value
  • between
  • start
  • end
String
  • equal
  • value
  • equal_property
  • value
  • not_equal
  • value
  • not_equal_property
  • value
  • starts_with
  • value
  • ends_with
  • value
  • contains
  • value
  • not_empty
  • is_empty
Boolean
  • is_true
  • is_false
List
  • in
  • values
  • not_in
  • values
  • contains
  • value
  • does_not_contain
  • value
  • includes_all
  • values
  • includes_none
  • values

Combining Conditions

  • if
  • then
  • and
  • or

Defining Actions

  • callOnTrue
  • args
  • callOnFalse
  • args
  • returnOnTrue
  • returnOnFalse

Examples

Validation

You'll probably want to validate that your rules are written correctly, so that an engine that adheres to the BRIJ specification can accurately parse, and evaluate your rules.

As a node library

npm install --save brij-spec

To validate your rule

var brijSpec = require('brij-spec');
var result = brijSpec.validate([{rule: {condition: "equal", property: "myProp"}}]);

More likely though, you'll want to validate a file with your rules defined

var fs = require('fs'),
    brijSpec = require('brij-spec');
var ruleData = fs.readFileSync('my-rule-file.json', 'utf8').toString();
var result = brijSpec.validate(ruleData);

Command line

There is also a command line client for your convenience.

npm install -g brij-spec

See brij-validate --help for usage:

Options:
  --filename, -f  JSON rules file to validate
  --quiet, -q     less output                  [default: false]
  --help, -h, -?  this help message

Getting Involved

We encourage anyone who's interested in participating in the formation of this standard to join the discussions here on GitHub. Also feel free to fork this project and submit new ideas to add to the brij-spec standard.

Versioning

brij-spec adheres to Semantic Versioning 2.0.0. If there is a violation of this scheme, report it as a bug. Specifically, if a patch or minor version is released and breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Any change that breaks the public API will only be introduced at a major-version release. As a result of this policy, you can (and should) specify any dependency on brij-spec by using the Pessimistic Version Constraint with two digits of precision.