├── .babelrc ├── .editorconfig ├── .eslintrc.json ├── .gitattributes ├── .gitignore ├── .huskyrc ├── .lintstagedrc ├── .npmignore ├── .prettierrc ├── .releaserc ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── commitlint.config.js ├── dist ├── jsonLogic.js ├── jsonLogic.js.map ├── jsonLogic.min.js └── jsonLogic.min.js.map ├── docs ├── README.md ├── add-examples-0.md ├── add-examples-1.md ├── add-examples-2.md ├── add-properties.md ├── add.md ├── all-examples-0-all-1--0.md ├── all-examples-0-all-1.md ├── all-examples-0.md ├── all-operators-oneof--.md ├── all-operators-oneof--1.md ├── all-operators-oneof--2.md ├── all-operators-oneof--3.md ├── all-operators-oneof--4.md ├── all-operators-oneof--5.md ├── all-operators-oneof--6.md ├── all-operators-oneof--7.md ├── all-operators-oneof--8.md ├── all-operators-oneof--9.md ├── all-operators-oneof-.md ├── all-operators-oneof-all.md ├── all-operators-oneof-and.md ├── all-operators-oneof-equal.md ├── all-operators-oneof-in.md ├── all-operators-oneof-log.md ├── all-operators-oneof-max.md ├── all-operators-oneof-method.md ├── all-operators-oneof-min.md ├── all-operators-oneof-missing.md ├── all-operators-oneof-missing_some.md ├── all-operators-oneof-none.md ├── all-operators-oneof-not-equal.md ├── all-operators-oneof-or.md ├── all-operators-oneof-some.md ├── all-operators-oneof-strict-equal.md ├── all-operators-oneof-strict-not-equal.md ├── all-operators-oneof-substr.md ├── all-operators-oneof-var.md ├── all-operators.md ├── all-properties.md ├── all-types-oneof-0.md ├── all-types-oneof-no-logic.md ├── all-types-wo-array-oneof-0.md ├── all-types-wo-array.md ├── all-types.md ├── all.md ├── and-examples-0.md ├── and-examples-1.md ├── and-examples-2.md ├── and-examples-3.md ├── and-properties.md ├── and.md ├── any-oneof-all-operators.md ├── any-wo-array-oneof-all.md ├── any-wo-array.md ├── any.md ├── binary-args-oneof-all.md ├── binary-args-oneof-array.md ├── binary-args.md ├── cat-examples-0.md ├── cat-examples-1-cat-1.md ├── cat-examples-1.md ├── cat-properties-1-or-more-args.md ├── cat-properties.md ├── cat.md ├── common │ ├── all-operators.json │ ├── all-types-wo-array.json │ ├── all-types.json │ ├── any-wo-array.json │ ├── any.json │ ├── binary-args.json │ ├── no-logic-object.json │ ├── one-or-more-args.json │ ├── pointer.json │ ├── trinary-args.json │ ├── unary-arg.json │ └── var.json ├── divide-examples-0.md ├── divide-properties.md ├── divide.md ├── equal-examples-0.md ├── equal-examples-1.md ├── equal-examples-2.md ├── equal-properties.md ├── equal.md ├── filter-examples-0-filter-0.md ├── filter-examples-0-filter-1--0.md ├── filter-examples-0-filter-1.md ├── filter-examples-0.md ├── filter-properties.md ├── filter.md ├── greater-examples-0.md ├── greater-properties.md ├── greater.md ├── greaterequal-examples-0.md ├── greaterequal-properties.md ├── greaterequal.md ├── if-examples-0.md ├── if-examples-1.md ├── if-examples-2-if-0--0.md ├── if-examples-2-if-0.md ├── if-examples-2-if-2--0.md ├── if-examples-2-if-2.md ├── if-examples-2.md ├── if-oneof-0-properties.md ├── if-oneof-0.md ├── if-oneof-1-properties.md ├── if-oneof-1.md ├── if.md ├── in-examples-0.md ├── in-properties.md ├── in.md ├── json-logic.json ├── json-logic.md ├── less-examples-0.md ├── less-examples-1.md ├── less-examples-2--1.md ├── less-examples-2.md ├── less-properties.md ├── less.md ├── lessequal-examples-0.md ├── lessequal-examples-1.md ├── lessequal-examples-2--1.md ├── lessequal-examples-2.md ├── lessequal-properties.md ├── lessequal.md ├── log-examples-0.md ├── log-properties.md ├── log.md ├── map-examples-0-map-0.md ├── map-examples-0-map-1--0.md ├── map-examples-0-map-1.md ├── map-examples-0.md ├── map-properties-binary-arg.md ├── map-properties.md ├── map.md ├── max-examples-0.md ├── max-properties.md ├── max.md ├── merge-examples-0.md ├── merge-examples-1.md ├── merge-properties.md ├── merge.md ├── method-examples-0-method-0.md ├── method-examples-0.md ├── method-examples-1.md ├── method-properties.md ├── method.md ├── min-examples-0.md ├── min-properties.md ├── min.md ├── missing-examples-0.md ├── missing-examples-1-if-0.md ├── missing-examples-1.md ├── missing-properties.md ├── missing.md ├── missing_some-examples-0.md ├── missing_some-examples-1.md ├── missing_some-properties-missing_some-items-need-count.md ├── missing_some-properties-missing_some.md ├── missing_some-properties.md ├── missing_some.md ├── modulo-examples-0.md ├── modulo-properties.md ├── modulo.md ├── multiply-examples-0.md ├── multiply-examples-1.md ├── multiply-properties.md ├── multiply.md ├── no-logic-object-oneof-empty-object.md ├── no-logic-object-oneof-non-logic-multiple-key-object.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-0.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-0.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-1.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-10.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-11.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-12.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-13.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-14.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-15.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-16.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-17.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-18.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-19.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-2.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-20.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-21.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-22.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-23.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-24.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-25.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-26.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-27.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-28.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-29.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-3.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-30.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-31.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-32.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-33.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-34.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-35.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-4.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-5.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-6.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-7.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-8.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not-oneof-9.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1-not.md ├── no-logic-object-oneof-non-logic-single-key-object-allof-1.md ├── no-logic-object-oneof-non-logic-single-key-object.md ├── no-logic-object.md ├── none-examples-0-none-1--0.md ├── none-examples-0-none-1.md ├── none-examples-0.md ├── none-properties.md ├── none.md ├── not-examples-0.md ├── not-examples-1.md ├── not-properties-unary-arg.md ├── not-properties.md ├── not.md ├── notequal-examples-0.md ├── notequal-examples-1.md ├── notequal-properties.md ├── notequal.md ├── notnot-examples-0.md ├── notnot-examples-1.md ├── notnot-properties.md ├── notnot.md ├── one-or-more-args-oneof-single-array-all.md ├── one-or-more-args-oneof-single-array.md ├── one-or-more-args.md ├── operators │ ├── accessor │ │ ├── missing.json │ │ ├── missing_some.json │ │ └── variable.json │ ├── arithmetic │ │ ├── add.json │ │ ├── divide.json │ │ ├── modulo.json │ │ ├── multiply.json │ │ └── subtract.json │ ├── array │ │ ├── all.json │ │ ├── filter.json │ │ ├── map.json │ │ ├── merge.json │ │ ├── none.json │ │ ├── reduce.json │ │ └── some.json │ ├── logic │ │ ├── and.json │ │ ├── equal.json │ │ ├── if.json │ │ ├── not.json │ │ ├── notEqual.json │ │ ├── notnot.json │ │ ├── or.json │ │ ├── strictEqual.json │ │ └── strictNotEqual.json │ ├── misc │ │ ├── in.json │ │ ├── log.json │ │ └── method.json │ ├── numeric │ │ ├── greater.json │ │ ├── greaterEqual.json │ │ ├── less.json │ │ ├── lessEqual.json │ │ ├── max.json │ │ └── min.json │ └── string │ │ ├── cat.json │ │ └── substr.json ├── or-examples-0.md ├── or-examples-1.md ├── or-examples-2.md ├── or-examples-3.md ├── or-properties.md ├── or.md ├── pointer-oneof-index.md ├── pointer-oneof-property.md ├── pointer.md ├── reduce-examples-0-reduce-0.md ├── reduce-examples-0-reduce-1--0.md ├── reduce-examples-0-reduce-1--1.md ├── reduce-examples-0-reduce-1.md ├── reduce-examples-0.md ├── reduce-properties-trinary-args.md ├── reduce-properties.md ├── reduce.md ├── some-examples-0-some-1--0.md ├── some-examples-0-some-1.md ├── some-examples-0.md ├── some-examples-1-some-0.md ├── some-examples-1-some-1--0.md ├── some-examples-1-some-1.md ├── some-examples-1.md ├── some-properties.md ├── some.md ├── strictequal-examples-0.md ├── strictequal-examples-1.md ├── strictequal-properties.md ├── strictequal.md ├── strictnotequal-examples-0.md ├── strictnotequal-examples-1.md ├── strictnotequal-properties.md ├── strictnotequal.md ├── substr-examples-0.md ├── substr-examples-1.md ├── substr-examples-2.md ├── substr-examples-3.md ├── substr-properties.md ├── substr.md ├── subtract-examples-0.md ├── subtract-examples-1.md ├── subtract-examples-2.md ├── subtract-properties.md ├── subtract.md ├── trinary-args-oneof-array.md ├── trinary-args.md ├── unary-arg-oneof-single-array.md ├── unary-arg.md ├── var-oneof-0-items-0-oneof-if.md ├── var-oneof-0-items-0-oneof-pointer.md ├── var-oneof-0-items-0.md ├── var-oneof-0-items-all.md ├── var-oneof-0.md ├── var-oneof-entire-data-object.md ├── var-oneof-filter.md ├── var-oneof-map.md ├── var-oneof-merge.md ├── var-oneof-null.md ├── var-oneof-reduce.md ├── var.md ├── variable-examples-0.md ├── variable-examples-1.md ├── variable-examples-2.md ├── variable-examples-3.md ├── variable-examples-4.md ├── variable-properties-var.md ├── variable-properties.md └── variable.md ├── jsonlogic.png ├── lib ├── createJsonLogic.js ├── helpers │ ├── arrayUnique.js │ ├── get_operator.js │ ├── get_values.js │ ├── isArray.js │ ├── is_logic.js │ ├── rule_like.js │ ├── truthy.js │ └── uses_data.js ├── index.js └── operations │ ├── accessor │ ├── index.js │ ├── missing.js │ ├── missing_some.js │ └── variable.js │ ├── arithmetic │ ├── add.js │ ├── divide.js │ ├── index.js │ ├── modulo.js │ ├── multiply.js │ └── subtract.js │ ├── array │ ├── all.js │ ├── filter.js │ ├── index.js │ ├── map.js │ ├── merge.js │ ├── none.js │ ├── reduce.js │ └── some.js │ ├── index.js │ ├── logic │ ├── and.js │ ├── condition.js │ ├── equal.js │ ├── index.js │ ├── not.js │ ├── notEqual.js │ ├── notnot.js │ ├── or.js │ ├── strictEqual.js │ └── strictNotEqual.js │ ├── misc │ ├── index.js │ ├── indexOf.js │ ├── log.js │ └── method.js │ ├── numeric │ ├── greater.js │ ├── greaterEqual.js │ ├── index.js │ ├── less.js │ ├── lessEqual.js │ ├── max.js │ └── min.js │ └── string │ ├── cat.js │ ├── index.js │ └── substr.js ├── package.json ├── play.html ├── rollup.config.js ├── schemas ├── common │ ├── all-operators.json │ ├── all-types-wo-array.json │ ├── all-types.json │ ├── any-wo-array.json │ ├── any.json │ ├── binary-args.json │ ├── no-logic-object.json │ ├── one-or-more-args.json │ ├── pointer.json │ ├── trinary-args.json │ ├── unary-arg.json │ └── var.json ├── json-logic.json └── operators │ ├── accessor │ ├── missing.json │ ├── missing_some.json │ └── variable.json │ ├── arithmetic │ ├── add.json │ ├── divide.json │ ├── modulo.json │ ├── multiply.json │ └── subtract.json │ ├── array │ ├── all.json │ ├── filter.json │ ├── map.json │ ├── merge.json │ ├── none.json │ ├── reduce.json │ └── some.json │ ├── logic │ ├── and.json │ ├── equal.json │ ├── if.json │ ├── not.json │ ├── notEqual.json │ ├── notnot.json │ ├── or.json │ ├── strictEqual.json │ └── strictNotEqual.json │ ├── misc │ ├── in.json │ ├── log.json │ └── method.json │ ├── numeric │ ├── greater.json │ ├── greaterEqual.json │ ├── less.json │ ├── lessEqual.json │ ├── max.json │ └── min.json │ └── string │ ├── cat.json │ └── substr.json ├── src ├── createJsonLogic.js ├── helpers │ ├── arrayUnique.js │ ├── get_operator.js │ ├── get_values.js │ ├── isArray.js │ ├── is_logic.js │ ├── rule_like.js │ ├── truthy.js │ └── uses_data.js ├── index.js └── operations │ ├── accessor │ ├── index.js │ ├── missing.js │ ├── missing_some.js │ └── variable.js │ ├── arithmetic │ ├── add.js │ ├── divide.js │ ├── index.js │ ├── modulo.js │ ├── multiply.js │ └── subtract.js │ ├── array │ ├── all.js │ ├── filter.js │ ├── index.js │ ├── map.js │ ├── merge.js │ ├── none.js │ ├── reduce.js │ └── some.js │ ├── index.js │ ├── logic │ ├── and.js │ ├── condition.js │ ├── equal.js │ ├── index.js │ ├── not.js │ ├── notEqual.js │ ├── notnot.js │ ├── or.js │ ├── strictEqual.js │ └── strictNotEqual.js │ ├── misc │ ├── index.js │ ├── indexOf.js │ ├── log.js │ └── method.js │ ├── numeric │ ├── greater.js │ ├── greaterEqual.js │ ├── index.js │ ├── less.js │ ├── lessEqual.js │ ├── max.js │ └── min.js │ └── string │ ├── cat.js │ ├── index.js │ └── substr.js └── tests └── tests.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "modules": false, 7 | "useBuiltIns": false 8 | } 9 | ] 10 | ], 11 | "plugins": [ 12 | "@babel/plugin-proposal-export-default-from" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | 10 | # Change these settings to your own preference 11 | indent_style = space 12 | indent_size = 2 13 | 14 | # We recommend you to keep these unchanged 15 | end_of_line = lf 16 | charset = utf-8 17 | trim_trailing_whitespace = true 18 | insert_final_newline = true 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false 22 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["airbnb", "plugin:prettier/recommended"], 3 | "rules": { 4 | "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], 5 | "no-use-before-define": ["error", { "functions": false }], 6 | "camelcase": "off" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Fix prettier: https://prettier.io/docs/en/options.html#end-of-line 2 | * text=auto eol=lf 3 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tests/*.json 3 | 4 | package-lock.json 5 | 6 | # editor and IDE remnants 7 | *~ 8 | .idea/ 9 | -------------------------------------------------------------------------------- /.huskyrc: -------------------------------------------------------------------------------- 1 | { 2 | "hooks": { 3 | "pre-commit": "lint-staged", 4 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "src/**/*.{js,jsx,json}": ["eslint --fix", "git add"], 3 | "(README|CONTRIBUTING).md": ["doctoc --title '**Table of Contents**'", "git add"] 4 | } 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | tests/tests.json 2 | src 3 | play.html 4 | 5 | .idea/ 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "semi": true, 4 | "singleQuote": true, 5 | "bracketSpacing": true, 6 | "endOfLine": "lf" 7 | } 8 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | ["@semantic-release/commit-analyzer", { 4 | "releaseRules": [ 5 | { "type": "refactor", "release": "patch" }, 6 | { "type": "docs", "release": "patch" }, 7 | ] 8 | }], 9 | "@semantic-release/release-notes-generator", 10 | ["@semantic-release/changelog", { 11 | "changelogFile": "CHANGELOG.md" 12 | }], 13 | ["@semantic-release/npm", { 14 | "npmPublish": true, 15 | }], 16 | ["@semantic-release/git", { 17 | "assets": ["docs", "dist", "lib", "CHANGELOG.md", "package.json"], 18 | "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" 19 | }] 20 | ], 21 | "branch": "master", 22 | "dryRun": false, 23 | "ci": false, 24 | } 25 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '10.15.1' 4 | cache: 5 | directories: 6 | - ".eslintcache" 7 | - "node_modules" 8 | install: 9 | - npm install 10 | script: 11 | - npm run lint 12 | - npm run lint:schemas 13 | - npm run test 14 | - npm run build 15 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | }; 4 | -------------------------------------------------------------------------------- /docs/add-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in + Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/add.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------ | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [add.json\*](operators/arithmetic/add.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/add-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in + Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/add.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------ | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [add.json\*](operators/arithmetic/add.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/add-examples-2.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in + Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/add.json#/examples/2 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------ | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [add.json\*](operators/arithmetic/add.json "open original schema") | 13 | 14 | ## 2 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/add-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in + Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/add.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------ | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [add.json\*](operators/arithmetic/add.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/all-examples-0-all-1--0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in all Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/all.json#/examples/0/all/1/>/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [all.json\*](operators/array/all.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/all-examples-0-all-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in all Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/all.json#/examples/0/all/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [all.json\*](operators/array/all.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/all-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in all Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/all.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [all.json\*](operators/array/all.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/all-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in all Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/all.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [all.json\*](operators/array/all.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/and-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in and Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/and.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [and.json\*](operators/logic/and.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/and-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in and Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/and.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [and.json\*](operators/logic/and.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/and-examples-2.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in and Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/and.json#/examples/2 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [and.json\*](operators/logic/and.json "open original schema") | 13 | 14 | ## 2 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/and-examples-3.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in and Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/and.json#/examples/3 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [and.json\*](operators/logic/and.json "open original schema") | 13 | 14 | ## 3 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/and-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in and Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/and.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [and.json\*](operators/logic/and.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/cat-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in cat Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/cat.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [cat.json\*](operators/string/cat.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/cat-examples-1-cat-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in cat Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/cat.json#/examples/1/cat/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [cat.json\*](operators/string/cat.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/cat-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in cat Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/cat.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [cat.json\*](operators/string/cat.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/cat-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in cat Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/cat.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [cat.json\*](operators/string/cat.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/common/all-types-wo-array.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/all-types-wo-array.json","title":"All","description":"Any valid JSON data type, except array primitive.","oneOf":[{"type":["boolean","null","number","string"]},{"$ref":"http://jsonlogic.com/schemas/common/no-logic-object.json"}]} 2 | -------------------------------------------------------------------------------- /docs/common/all-types.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/all-types.json","title":"All","description":"Any valid JSON data type.","oneOf":[{"type":["boolean","null","number","string","array"]},{"$ref":"http://jsonlogic.com/schemas/common/no-logic-object.json"}]} 2 | -------------------------------------------------------------------------------- /docs/common/any-wo-array.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/any-wo-array.json","title":"All","description":"Any valid JSON Logic data source, except array primitive.","oneOf":[{"$ref":"http://jsonlogic.com/schemas/common/all-operators.json"},{"$ref":"http://jsonlogic.com/schemas/common/all-types-wo-array.json"}]} 2 | -------------------------------------------------------------------------------- /docs/common/any.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/any.json","title":"All","description":"Any valid JSON Logic data source.","oneOf":[{"$ref":"http://jsonlogic.com/schemas/common/all-operators.json"},{"$ref":"http://jsonlogic.com/schemas/common/all-types.json"}]} 2 | -------------------------------------------------------------------------------- /docs/common/binary-args.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/binary-args.json","title":"Binary Arg","description":"Up to two args of valid JSON Logic data source.","oneOf":[{"title":"Array","description":"An array with one or two elements.","type":"array","minItems":1,"maxItems":2,"items":{"$ref":"http://jsonlogic.com/schemas/common/any.json"}},{"$ref":"http://jsonlogic.com/schemas/common/any-wo-array.json","title":"Single Arg","description":"Note: binary operators can also take a single, non array argument:"}]} 2 | -------------------------------------------------------------------------------- /docs/common/one-or-more-args.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/one-or-more-args.json","title":"1 or more args","description":"With 1 or more arguments.","oneOf":[{"title":"Single Array","description":"An array with 1 or more elements.","type":"array","items":{"$ref":"http://jsonlogic.com/schemas/common/any.json"}},{"$ref":"http://jsonlogic.com/schemas/common/any-wo-array.json","title":"Single Arg","description":"Note: 1 or more operators can also take a single, non array argument:"}]} 2 | -------------------------------------------------------------------------------- /docs/common/pointer.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/pointer.json","title":"Pointer","description":"Schema to access properties of an object or items of an array by index.","oneOf":[{"type":"string","title":"Property","description":"The key passed to var can use dot-notation to get the property of a property (to any depth you need):","minLength":1},{"type":"integer","title":"Index","description":"You can also use the var operator to access an array by numeric index.","minimum":0}]} 2 | -------------------------------------------------------------------------------- /docs/common/trinary-args.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/trinary-args.json","title":"Trinary Args","description":"Up to three args of valid JSON Logic data source.","oneOf":[{"title":"Array","description":"An array with one or three elements.","type":"array","minItems":1,"maxItems":3,"items":{"$ref":"http://jsonlogic.com/schemas/common/any.json"}},{"$ref":"http://jsonlogic.com/schemas/common/any-wo-array.json","title":"Single Arg","description":"Note: trinary operators can also take a single, non array argument:"}]} 2 | -------------------------------------------------------------------------------- /docs/common/unary-arg.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/common/unary-arg.json","title":"Unary Arg","description":"Only one valid JSON Logic data source.","oneOf":[{"title":"Single Array","description":"An array with just one element.","type":"array","minItems":1,"maxItems":1,"items":{"$ref":"http://jsonlogic.com/schemas/common/any.json"}},{"$ref":"http://jsonlogic.com/schemas/common/any-wo-array.json","title":"Single Arg","description":"Note: unary operators can also take a single, non array argument:"}]} 2 | -------------------------------------------------------------------------------- /docs/divide-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in / Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/divide.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------------ | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [divide.json\*](operators/arithmetic/divide.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/divide-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in / Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/divide.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------------ | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [divide.json\*](operators/arithmetic/divide.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/equal-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in Equal Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/equal.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [equal.json\*](operators/logic/equal.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/equal-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in Equal Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/equal.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [equal.json\*](operators/logic/equal.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/equal-examples-2.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in Equal Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/equal.json#/examples/2 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [equal.json\*](operators/logic/equal.json "open original schema") | 13 | 14 | ## 2 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/equal-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in Equal Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/equal.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [equal.json\*](operators/logic/equal.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/filter-examples-0-filter-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in filter Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/filter.json#/examples/0/filter/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [filter.json\*](operators/array/filter.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/filter-examples-0-filter-1--0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in filter Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/filter.json#/examples/0/filter/1/%/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [filter.json\*](operators/array/filter.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/filter-examples-0-filter-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in filter Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/filter.json#/examples/0/filter/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [filter.json\*](operators/array/filter.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/filter-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in filter Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/filter.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [filter.json\*](operators/array/filter.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/filter-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in filter Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/filter.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [filter.json\*](operators/array/filter.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/greater-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in > Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/numeric/greater.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [greater.json\*](operators/numeric/greater.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/greater-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in > Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/numeric/greater.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [greater.json\*](operators/numeric/greater.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/if-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in if Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/if.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [if.json\*](operators/logic/if.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/if-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in if Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/if.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [if.json\*](operators/logic/if.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/if-examples-2-if-0--0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in if Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/if.json#/examples/2/if/0//0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [none.json\*](operators/array/none.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/none-examples-0-none-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in none Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/none.json#/examples/0/none/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [none.json\*](operators/array/none.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/none-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in none Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/none.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [none.json\*](operators/array/none.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/none-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in none Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/none.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [none.json\*](operators/array/none.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/not-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in ! Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/not.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [not.json\*](operators/logic/not.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/not-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in ! Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/not.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [not.json\*](operators/logic/not.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/not-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in ! Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/not.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [not.json\*](operators/logic/not.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/notequal-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in Not-Equal Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/notEqual.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [notEqual.json\*](operators/logic/notEqual.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/notequal-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in Not-Equal Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/notEqual.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [notEqual.json\*](operators/logic/notEqual.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/notequal-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in Not-Equal Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/notEqual.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [notEqual.json\*](operators/logic/notEqual.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/notnot-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in !! Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/notnot.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [notnot.json\*](operators/logic/notnot.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/notnot-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in !! Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/notnot.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [notnot.json\*](operators/logic/notnot.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/notnot-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in !! Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/notnot.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [notnot.json\*](operators/logic/notnot.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/operators/accessor/missing.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/accessor/missing.json","title":"missing","description":"Takes an array of data keys to search for (same format as var). Returns an array of any keys that are missing from the data object, or an empty array.","type":"object","additionalProperties":false,"required":["missing"],"properties":{"missing":{"$ref":"http://jsonlogic.com/schemas/common/var.json"}},"examples":[{"missing":["a","b"]},{"if":[{"missing":["a","b"]},"'a' and/or 'b' are missing","OK to proceed"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/accessor/missing_some.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/accessor/missing_some.json","title":"missing_some","description":"Takes a minimum number of data keys that are required, and an array of keys to search for (same format as var or missing). Returns an empty array if the minimum is met, or an array of the missing keys otherwise.","type":"object","additionalProperties":false,"required":["missing_some"],"properties":{"missing_some":{"type":"array","minItems":2,"maxItems":2,"items":[{"type":"integer","title":"Need-Count","description":"Takes a minimum number of data keys that are required"},{"$ref":"http://jsonlogic.com/schemas/common/var.json","description":"An array of keys to search for (same format as var or missing)."}]}},"examples":[{"missing_some":[1,["a","b","c"]]},{"missing_some":[2,["a","b","c"]]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/accessor/variable.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/accessor/variable.json","title":"var","description":"Retrieve data from the provided data object.","type":"object","additionalProperties":false,"required":["var"],"properties":{"var":{"$ref":"http://jsonlogic.com/schemas/common/var.json"}},"examples":[{"var":["a"]},{"var":["z",26]},{"var":"champ.name"},{"var":1},{"var":""}]} 2 | -------------------------------------------------------------------------------- /docs/operators/arithmetic/add.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/arithmetic/add.json","title":"+","description":"Addition. Because addition is associative, it happily take as many args as you want. Passing just one argument to + casts it to a number.","type":"object","additionalProperties":false,"required":["+"],"properties":{"+":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"+":[4,2]},{"+":[2,2,2,2,2]},{"+":"3.14"}]} 2 | -------------------------------------------------------------------------------- /docs/operators/arithmetic/divide.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/arithmetic/divide.json","title":"/","description":"Division.","type":"object","additionalProperties":false,"required":["/"],"properties":{"/":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"/":[4,2]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/arithmetic/modulo.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/arithmetic/modulo.json","title":"%","description":"Module. Finds the remainder after the first argument is divided by the second argument.","type":"object","additionalProperties":false,"required":["%"],"properties":{"%":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"%":[101,2]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/arithmetic/multiply.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/arithmetic/multiply.json","title":"*","description":"Multiplication. Because multiplication is associative, it happily take as many args as you want.","type":"object","additionalProperties":false,"required":["*"],"properties":{"*":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"*":[4,2]},{"*":[2,2,2,2,2]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/arithmetic/subtract.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/arithmetic/subtract.json","title":"-","description":"Subtraction. Passing just one argument to - returns its arithmetic negative (additive inverse).","type":"object","additionalProperties":false,"required":["-"],"properties":{"-":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"-":[4,2]},{"-":2},{"-":-2}]} 2 | -------------------------------------------------------------------------------- /docs/operators/array/all.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/array/all.json","title":"all","description":"These operations take an array, and perform a test on each member of that array.\nThe most interesting part of these operations is that inside the test code, var operations are relative to the array element being tested.\nIt can be useful to use {\"var\":\"\"} to get the entire array element within the test.","type":"object","additionalProperties":false,"required":["all"],"properties":{"all":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"all":[[1,2,3],{">":[{"var":""},0]}]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/array/filter.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/array/filter.json","title":"filter","description":"You can use filter to keep only elements of the array that pass a test. Note, that inside the logic being used to map, var operations are relative to the array element being worked on.","type":"object","additionalProperties":false,"required":["filter"],"properties":{"filter":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"filter":[{"var":"integers"},{"%":[{"var":""},2]}]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/array/map.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/array/map.json","title":"map","description":"You can use map to perform an action on every member of an array. Note, that inside the logic being used to map, var operations are relative to the array element being worked on.","type":"object","additionalProperties":false,"required":["map"],"properties":{"map":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"map":[{"var":"integers"},{"*":[{"var":""},2]}]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/array/merge.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/array/merge.json","title":"merge","description":"Takes one or more arrays, and merges them into one array. If arguments aren’t arrays, they get cast to arrays.","type":"object","additionalProperties":false,"required":["merge"],"properties":{"merge":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"merge":[[1,2],[3,4]]},{"merge":[1,2,[3,4]]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/array/none.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/array/none.json","title":"none","description":"These operations take an array, and perform a test on each member of that array.\nThe most interesting part of these operations is that inside the test code, var operations are relative to the array element being tested.\nIt can be useful to use {\"var\":\"\"} to get the entire array element within the test.","type":"object","additionalProperties":false,"required":["none"],"properties":{"none":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"none":[[-3,-2,-1],{">":[{"var":""},0]}]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/array/reduce.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/array/reduce.json","title":"reduce","description":"You can use reduce to combine all the elements in an array into a single value, like adding up a list of numbers. Note, that inside the logic being used to reduce, var operations only have access to an object like: {\n \"current\" : // this element of the array,\n \"accumulator\" : // progress so far, or the initial value\n}","type":"object","additionalProperties":false,"required":["reduce"],"properties":{"reduce":{"$ref":"http://jsonlogic.com/schemas/common/trinary-args.json"}},"examples":[{"reduce":[{"var":"integers"},{"+":[{"var":"current"},{"var":"accumulator"}]},0]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/array/some.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/array/some.json","title":"some","description":"These operations take an array, and perform a test on each member of that array.\nThe most interesting part of these operations is that inside the test code, var operations are relative to the array element being tested.\nIt can be useful to use {\"var\":\"\"} to get the entire array element within the test.","type":"object","additionalProperties":false,"required":["some"],"properties":{"some":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"some":[[-1,0,1],{">":[{"var":""},0]}]},{"some":[{"var":"pies"},{"==":[{"var":"filling"},"apple"]}]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/and.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/and.json","title":"and","description":"and can be used for simple boolean tests, with 1 or more arguments. At a more sophisticated level, and returns the first falsy argument, or the last argument.","type":"object","additionalProperties":false,"required":["and"],"properties":{"and":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"and":[true,true]},{"and":[true,false]},{"and":[true,"a",3]},{"and":[true,"",3]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/equal.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/equal.json","title":"Equal","description":"Tests equality, with type coercion. Requires two arguments.","type":"object","additionalProperties":false,"required":["=="],"properties":{"==":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"==":[1,1]},{"==":[1,"1"]},{"==":[0,false]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/if.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/if.json","title":"if","description":"The if statement typically takes 3 arguments: a condition (if), what to do if it’s true (then), and what to do if it’s false (else), like: {\"if\" : [ true, \"yes\", \"no\" ]}.\nIf can also take more than 3 arguments, and will pair up arguments like if/then elseif/then elseif/then else.","oneOf":[{"type":"object","additionalProperties":false,"required":["if"],"properties":{"if":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}}},{"type":"object","additionalProperties":false,"required":["?:"],"properties":{"?:":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}}}],"examples":[{"if":[true,"yes","no"]},{"if":[false,"yes","no"]},{"if":[{"<":[{"var":"temp"},0]},"freezing",{"<":[{"var":"temp"},100]},"liquid","gas"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/not.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/not.json","title":"!","description":"Logical negation (“not”). Takes just one argument.","type":"object","additionalProperties":false,"required":["!"],"properties":{"!":{"$ref":"http://jsonlogic.com/schemas/common/unary-arg.json"}},"examples":[{"!":[true]},{"!":true}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/notEqual.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/notEqual.json","title":"Not-Equal","description":"Tests not-equal, with type coercion. Requires two arguments.","type":"object","additionalProperties":false,"required":["!="],"properties":{"!=":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"!=":[1,2]},{"!=":[1,"1"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/notnot.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/notnot.json","title":"!!","description":"Double negation, or “cast to a boolean.” Takes a single argument.","type":"object","additionalProperties":false,"required":["!!"],"properties":{"!!":{"$ref":"http://jsonlogic.com/schemas/common/unary-arg.json"}},"examples":[{"!!":[[]]},{"!!":["0"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/or.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/or.json","title":"or","description":"or can be used for simple boolean tests, with 1 or more arguments. At a more sophisticated level, or returns the first truthy argument, or the last argument.","type":"object","additionalProperties":false,"required":["or"],"properties":{"or":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"or":[true,false]},{"or":[false,true]},{"or":[false,"a"]},{"or":[false,0,"a"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/strictEqual.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/strictEqual.json","title":"Strict Equal","description":"Tests strict equality. Requires two arguments.","type":"object","additionalProperties":false,"required":["==="],"properties":{"===":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"===":[1,1]},{"===":[1,"1"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/logic/strictNotEqual.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/logic/strictNotEqual.json","title":"Strict Not-Equal","description":"Tests strict not-equal. Requires two arguments.","type":"object","additionalProperties":false,"required":["!=="],"properties":{"!==":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"!==":[1,2]},{"!==":[1,"1"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/misc/in.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/misc/in.json","title":"in","description":"If the second argument is an array, tests that the first argument is a member of the array: {\"in\":[ \"Ringo\", [\"John\", \"Paul\", \"George\", \"Ringo\"] ]}.\nIf the second argument is a string, tests that the first argument is a substring: {\"in\":[\"Spring\", \"Springfield\"]}.","type":"object","additionalProperties":false,"required":["in"],"properties":{"in":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{"in":["Spring","Springfield"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/misc/log.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/misc/log.json","title":"log","description":"Logs the first value to console, then passes it through unmodified.","type":"object","additionalProperties":false,"required":["log"],"properties":{"log":{"$ref":"http://jsonlogic.com/schemas/common/any.json"}},"examples":[{"log":"apple"}]} 2 | -------------------------------------------------------------------------------- /docs/operators/misc/method.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/misc/method.json","title":"method","description":"If your rule needs to call a method on an object, you can use the built-in method operation.\n You can also pass an array of arguments into the method.","type":"object","additionalProperties":false,"required":["method"],"properties":{"method":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"method":[{"var":"today"},"getDay"]},{"method":["automaton","slice",[2,8]]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/numeric/greater.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/numeric/greater.json","title":">","description":"Greater than.","type":"object","additionalProperties":false,"required":[">"],"properties":{">":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{">":[2,1]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/numeric/greaterEqual.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/numeric/greaterEqual.json","title":">=","description":"Greater than or equal to.","type":"object","additionalProperties":false,"required":[">="],"properties":{">=":{"$ref":"http://jsonlogic.com/schemas/common/binary-args.json"}},"examples":[{">=":[1,1]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/numeric/less.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/numeric/less.json","title":"<","description":"Less than. You can use a special case of < to test that one value is exclusively between two others.","type":"object","additionalProperties":false,"required":["<"],"properties":{"<":{"$ref":"http://jsonlogic.com/schemas/common/trinary-args.json"}},"examples":[{"<":[1,2]},{"<":[1,2,3]},{"<":[0,{"var":"temp"},100]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/numeric/lessEqual.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/numeric/lessEqual.json","title":"<=","description":"Less than or equal to. You can use a special case of <= to test that one value is inclusively between two others.","type":"object","additionalProperties":false,"required":["<="],"properties":{"<=":{"$ref":"http://jsonlogic.com/schemas/common/trinary-args.json"}},"examples":[{"<=":[1,1]},{"<=":[1,2,3]},{"<=":[0,{"var":"temp"},100]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/numeric/max.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/numeric/max.json","title":"max","description":"Return the maximum from a list of values.","type":"object","additionalProperties":false,"required":["max"],"properties":{"max":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"max":[1,2,3]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/numeric/min.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/numeric/min.json","title":"min","description":"Return the minimum from a list of values.","type":"object","additionalProperties":false,"required":["min"],"properties":{"min":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"min":[1,2,3]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/string/cat.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/string/cat.json","title":"cat","description":"Concatenate all the supplied arguments. Note that this is not a join or implode operation, there is no “glue” string.","type":"object","additionalProperties":false,"required":["cat"],"properties":{"cat":{"$ref":"http://jsonlogic.com/schemas/common/one-or-more-args.json"}},"examples":[{"cat":["I love"," pie"]},{"cat":["I love ",{"var":"filling"}," pie"]}]} 2 | -------------------------------------------------------------------------------- /docs/operators/string/substr.json: -------------------------------------------------------------------------------- 1 | {"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://jsonlogic.com/schemas/operators/string/substr.json","title":"substr","description":"Get a portion of a string.\n\nGive a positive start position to return everything beginning at that index (Indexes of course start at zero).\nGive a negative start position to work backwards from the end of the string, then return everything.\nGive a positive length to express how many characters to return.\nGive a negative length to stop that many characters before the end.","type":"object","additionalProperties":false,"required":["substr"],"properties":{"substr":{"$ref":"http://jsonlogic.com/schemas/common/trinary-args.json"}},"examples":[{"substr":["jsonlogic",4]},{"substr":["jsonlogic",-5]},{"substr":["jsonlogic",1,3]},{"substr":["jsonlogic",4,-2]}]} 2 | -------------------------------------------------------------------------------- /docs/or-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in or Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/or.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [or.json\*](operators/logic/or.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/or-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in or Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/or.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [or.json\*](operators/logic/or.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/or-examples-2.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in or Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/or.json#/examples/2 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [or.json\*](operators/logic/or.json "open original schema") | 13 | 14 | ## 2 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/or-examples-3.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in or Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/or.json#/examples/3 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [or.json\*](operators/logic/or.json "open original schema") | 13 | 14 | ## 3 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/or-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in or Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/logic/or.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ----------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [or.json\*](operators/logic/or.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/reduce-examples-0-reduce-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in reduce Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/reduce.json#/examples/0/reduce/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [reduce.json\*](operators/array/reduce.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/reduce-examples-0-reduce-1--0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in reduce Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/reduce.json#/examples/0/reduce/1/+/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [reduce.json\*](operators/array/reduce.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/reduce-examples-0-reduce-1--1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in reduce Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/reduce.json#/examples/0/reduce/1/+/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [reduce.json\*](operators/array/reduce.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/reduce-examples-0-reduce-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in reduce Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/reduce.json#/examples/0/reduce/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [reduce.json\*](operators/array/reduce.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/reduce-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in reduce Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/reduce.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [reduce.json\*](operators/array/reduce.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/reduce-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in reduce Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/reduce.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [reduce.json\*](operators/array/reduce.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/some-examples-0-some-1--0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in some Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/some.json#/examples/0/some/1/>/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [some.json\*](operators/array/some.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/some-examples-0-some-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in some Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/some.json#/examples/0/some/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [some.json\*](operators/array/some.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/some-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in some Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/some.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [some.json\*](operators/array/some.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/some-examples-1-some-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in some Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/some.json#/examples/1/some/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [some.json\*](operators/array/some.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/some-examples-1-some-1--0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in some Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/some.json#/examples/1/some/1/==/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [some.json\*](operators/array/some.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/some-examples-1-some-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in some Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/some.json#/examples/1/some/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [some.json\*](operators/array/some.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/some-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in some Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/some.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [some.json\*](operators/array/some.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/some-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in some Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/array/some.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | --------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [some.json\*](operators/array/some.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/substr-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in substr Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/substr.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [substr.json\*](operators/string/substr.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/substr-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in substr Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/substr.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [substr.json\*](operators/string/substr.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/substr-examples-2.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in substr Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/substr.json#/examples/2 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [substr.json\*](operators/string/substr.json "open original schema") | 13 | 14 | ## 2 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/substr-examples-3.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in substr Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/substr.json#/examples/3 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [substr.json\*](operators/string/substr.json "open original schema") | 13 | 14 | ## 3 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/substr-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in substr Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/string/substr.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [substr.json\*](operators/string/substr.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/subtract-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in - Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/subtract.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ---------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [subtract.json\*](operators/arithmetic/subtract.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/subtract-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in - Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/subtract.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ---------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [subtract.json\*](operators/arithmetic/subtract.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/subtract-examples-2.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in - Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/arithmetic/subtract.json#/examples/2 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ---------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [subtract.json\*](operators/arithmetic/subtract.json "open original schema") | 13 | 14 | ## 2 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/var-oneof-null.md: -------------------------------------------------------------------------------- 1 | # Null Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/common/var.json#/oneOf/7 5 | ``` 6 | 7 | Unknown null. 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ---------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [var.json\*](common/var.json "open original schema") | 13 | 14 | ## 7 Type 15 | 16 | `null`, the value must be null ([Null](var-oneof-null.md)) 17 | -------------------------------------------------------------------------------- /docs/variable-examples-0.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in var Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/accessor/variable.json#/examples/0 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [variable.json\*](operators/accessor/variable.json "open original schema") | 13 | 14 | ## 0 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/variable-examples-1.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in var Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/accessor/variable.json#/examples/1 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [variable.json\*](operators/accessor/variable.json "open original schema") | 13 | 14 | ## 1 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/variable-examples-2.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in var Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/accessor/variable.json#/examples/2 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [variable.json\*](operators/accessor/variable.json "open original schema") | 13 | 14 | ## 2 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/variable-examples-3.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in var Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/accessor/variable.json#/examples/3 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [variable.json\*](operators/accessor/variable.json "open original schema") | 13 | 14 | ## 3 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/variable-examples-4.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in var Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/accessor/variable.json#/examples/4 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [variable.json\*](operators/accessor/variable.json "open original schema") | 13 | 14 | ## 4 Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /docs/variable-properties.md: -------------------------------------------------------------------------------- 1 | # Untitled undefined type in var Schema 2 | 3 | ```txt 4 | http://jsonlogic.com/schemas/operators/accessor/variable.json#/properties 5 | ``` 6 | 7 | 8 | 9 | 10 | | Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In | 11 | | :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | -------------------------------------------------------------------------- | 12 | | Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [variable.json\*](operators/accessor/variable.json "open original schema") | 13 | 14 | ## properties Type 15 | 16 | unknown 17 | -------------------------------------------------------------------------------- /jsonlogic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/axa-ch/json-logic-js/59280d900a75be477e6420143cad3d83b2760494/jsonlogic.png -------------------------------------------------------------------------------- /lib/helpers/arrayUnique.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Return an array that contains no duplicates (original not modified) 3 | * @param {array} array Original reference array 4 | * @return {array} New array with no duplicates 5 | */ 6 | function arrayUnique(array) { 7 | var a = []; 8 | 9 | for (var i = 0, l = array.length; i < l; i++) { 10 | if (a.indexOf(array[i]) === -1) { 11 | a.push(array[i]); 12 | } 13 | } 14 | 15 | return a; 16 | } 17 | 18 | export default arrayUnique; -------------------------------------------------------------------------------- /lib/helpers/get_operator.js: -------------------------------------------------------------------------------- 1 | function get_operator(logic) { 2 | return Object.keys(logic)[0]; 3 | } 4 | 5 | export default get_operator; -------------------------------------------------------------------------------- /lib/helpers/get_values.js: -------------------------------------------------------------------------------- 1 | import get_operator from './get_operator'; 2 | 3 | function get_values(logic) { 4 | return logic[get_operator(logic)]; 5 | } 6 | 7 | export default get_values; -------------------------------------------------------------------------------- /lib/helpers/isArray.js: -------------------------------------------------------------------------------- 1 | export default Array.isArray; -------------------------------------------------------------------------------- /lib/helpers/is_logic.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | import isArray from './isArray'; 4 | 5 | function is_logic(logic) { 6 | return _typeof(logic) === 'object' && // An object 7 | logic !== null && // but not null 8 | !isArray(logic) && // and not an array 9 | Object.keys(logic).length === 1 // with exactly one key 10 | ; 11 | } 12 | 13 | export default is_logic; -------------------------------------------------------------------------------- /lib/helpers/truthy.js: -------------------------------------------------------------------------------- 1 | import isArray from './isArray'; 2 | /* 3 | This helper will defer to the JsonLogic spec as a tie-breaker when different language interpreters define different behavior for the truthiness of primitives. E.g., PHP considers empty arrays to be falsy, but Javascript considers them to be truthy. JsonLogic, as an ecosystem, needs one consistent answer. 4 | 5 | Spec and rationale here: http://jsonlogic.com/truthy 6 | */ 7 | 8 | function truthy(value) { 9 | if (isArray(value) && value.length === 0) { 10 | return false; 11 | } 12 | 13 | return !!value; 14 | } 15 | 16 | export default truthy; -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | import createJsonLogic from './createJsonLogic'; 2 | import * as operations from './operations'; 3 | import is_logic from './helpers/is_logic'; 4 | import truthy from './helpers/truthy'; 5 | import get_operator from './helpers/get_operator'; 6 | import get_values from './helpers/get_values'; 7 | import uses_data from './helpers/uses_data'; 8 | import rule_like from './helpers/rule_like'; 9 | var jsonLogic = createJsonLogic(operations); // restore original public API 10 | 11 | jsonLogic.is_logic = is_logic; 12 | jsonLogic.truthy = truthy; 13 | jsonLogic.get_operator = get_operator; 14 | jsonLogic.get_values = get_values; 15 | jsonLogic.uses_data = uses_data; 16 | jsonLogic.rule_like = rule_like; 17 | export default jsonLogic; -------------------------------------------------------------------------------- /lib/operations/accessor/index.js: -------------------------------------------------------------------------------- 1 | export { default as variable } from './variable'; 2 | export { default as missing } from './missing'; 3 | export { default as missing_some } from './missing_some'; -------------------------------------------------------------------------------- /lib/operations/accessor/missing_some.js: -------------------------------------------------------------------------------- 1 | function missing_some(apply, need_count, options) { 2 | // missing_some takes two arguments, how many (minimum) items must be present, and an array of keys (just like 'missing') to check for presence. 3 | var are_missing = apply({ 4 | missing: options 5 | }, this); 6 | 7 | if (options.length - are_missing.length >= need_count) { 8 | return []; 9 | } 10 | 11 | return are_missing; 12 | } 13 | 14 | missing_some.withApply = true; 15 | export default missing_some; -------------------------------------------------------------------------------- /lib/operations/accessor/variable.js: -------------------------------------------------------------------------------- 1 | function variable(a, b) { 2 | var not_found = b === undefined ? null : b; 3 | var data = this; 4 | 5 | if (typeof a === 'undefined' || a === '' || a === null) { 6 | return data; 7 | } 8 | 9 | var sub_props = String(a).split('.'); 10 | 11 | for (var i = 0; i < sub_props.length; i++) { 12 | if (data === null) { 13 | return not_found; 14 | } // Descending into data 15 | 16 | 17 | data = data[sub_props[i]]; 18 | 19 | if (data === undefined) { 20 | return not_found; 21 | } 22 | } 23 | 24 | return data; 25 | } 26 | 27 | variable.op = 'var'; 28 | export default variable; -------------------------------------------------------------------------------- /lib/operations/arithmetic/add.js: -------------------------------------------------------------------------------- 1 | function add() { 2 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 3 | args[_key] = arguments[_key]; 4 | } 5 | 6 | return args.reduce(function (a, b) { 7 | return parseFloat(a, 10) + parseFloat(b, 10); 8 | }, 0); 9 | } 10 | 11 | add.op = '+'; 12 | export default add; -------------------------------------------------------------------------------- /lib/operations/arithmetic/divide.js: -------------------------------------------------------------------------------- 1 | function divide(a, b) { 2 | return a / b; 3 | } 4 | 5 | divide.op = '/'; 6 | export default divide; -------------------------------------------------------------------------------- /lib/operations/arithmetic/index.js: -------------------------------------------------------------------------------- 1 | export { default as add } from './add'; 2 | export { default as divide } from './divide'; 3 | export { default as modulo } from './modulo'; 4 | export { default as multiply } from './multiply'; 5 | export { default as subtract } from './subtract'; -------------------------------------------------------------------------------- /lib/operations/arithmetic/modulo.js: -------------------------------------------------------------------------------- 1 | function modulo(a, b) { 2 | return a % b; 3 | } 4 | 5 | modulo.op = '%'; 6 | export default modulo; -------------------------------------------------------------------------------- /lib/operations/arithmetic/multiply.js: -------------------------------------------------------------------------------- 1 | function multiply() { 2 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 3 | args[_key] = arguments[_key]; 4 | } 5 | 6 | return args.reduce(function (a, b) { 7 | return parseFloat(a, 10) * parseFloat(b, 10); 8 | }, 1); 9 | } 10 | 11 | multiply.op = '*'; 12 | export default multiply; -------------------------------------------------------------------------------- /lib/operations/arithmetic/subtract.js: -------------------------------------------------------------------------------- 1 | function subtract(a, b) { 2 | if (b === undefined) { 3 | return -a; 4 | } 5 | 6 | return a - b; 7 | } 8 | 9 | subtract.op = '-'; 10 | export default subtract; -------------------------------------------------------------------------------- /lib/operations/array/all.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | function all(apply, data, values) { 4 | var scopedData = apply(values[0], data); 5 | var scopedLogic = values[1]; // All of an empty set is false. Note, some and none have correct fallback after the for loop 6 | 7 | if (!scopedData.length) { 8 | return false; 9 | } 10 | 11 | for (var i = 0; i < scopedData.length; i += 1) { 12 | if (!truthy(apply(scopedLogic, scopedData[i]))) { 13 | return false; // First falsy, short circuit 14 | } 15 | } 16 | 17 | return true; // All were truthy 18 | } 19 | 20 | all.deepFirst = false; 21 | export default all; -------------------------------------------------------------------------------- /lib/operations/array/filter.js: -------------------------------------------------------------------------------- 1 | import isArray from '../../helpers/isArray'; 2 | import truthy from '../../helpers/truthy'; 3 | 4 | function filter(apply, data, values) { 5 | var scopedData = apply(values[0], data); 6 | var scopedLogic = values[1]; 7 | 8 | if (!isArray(scopedData)) { 9 | return []; 10 | } // Return only the elements from the array in the first argument, 11 | // that return truthy when passed to the logic in the second argument. 12 | // For parity with JavaScript, reindex the returned array 13 | 14 | 15 | return scopedData.filter(function (datum) { 16 | return truthy(apply(scopedLogic, datum)); 17 | }); 18 | } 19 | 20 | filter.deepFirst = false; 21 | export default filter; -------------------------------------------------------------------------------- /lib/operations/array/index.js: -------------------------------------------------------------------------------- 1 | export { default as all } from './all'; 2 | export { default as filter } from './filter'; 3 | export { default as map } from './map'; 4 | export { default as merge } from './merge'; 5 | export { default as none } from './none'; 6 | export { default as reduce } from './reduce'; 7 | export { default as some } from './some'; -------------------------------------------------------------------------------- /lib/operations/array/map.js: -------------------------------------------------------------------------------- 1 | import isArray from '../../helpers/isArray'; 2 | 3 | function map(apply, data, values) { 4 | var scopedData = apply(values[0], data); 5 | var scopedLogic = values[1]; 6 | 7 | if (!isArray(scopedData)) { 8 | return []; 9 | } 10 | 11 | return scopedData.map(function (datum) { 12 | return apply(scopedLogic, datum); 13 | }); 14 | } 15 | 16 | map.deepFirst = false; 17 | export default map; -------------------------------------------------------------------------------- /lib/operations/array/merge.js: -------------------------------------------------------------------------------- 1 | function merge() { 2 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 3 | args[_key] = arguments[_key]; 4 | } 5 | 6 | return args.reduce(function (a, b) { 7 | return a.concat(b); 8 | }, []); 9 | } 10 | 11 | export default merge; -------------------------------------------------------------------------------- /lib/operations/array/none.js: -------------------------------------------------------------------------------- 1 | function none(apply, data, values) { 2 | var filtered = apply({ 3 | filter: values 4 | }, data); 5 | return filtered.length === 0; 6 | } 7 | 8 | none.deepFirst = false; 9 | export default none; -------------------------------------------------------------------------------- /lib/operations/array/reduce.js: -------------------------------------------------------------------------------- 1 | import isArray from '../../helpers/isArray'; 2 | 3 | function reduce(apply, data, values) { 4 | var scopedData = apply(values[0], data); 5 | var scopedLogic = values[1]; 6 | var initial = typeof values[2] !== 'undefined' ? values[2] : null; 7 | 8 | if (!isArray(scopedData)) { 9 | return initial; 10 | } 11 | 12 | return scopedData.reduce(function (accumulator, current) { 13 | return apply(scopedLogic, { 14 | current: current, 15 | accumulator: accumulator 16 | }); 17 | }, initial); 18 | } 19 | 20 | reduce.deepFirst = false; 21 | export default reduce; -------------------------------------------------------------------------------- /lib/operations/array/some.js: -------------------------------------------------------------------------------- 1 | function some(apply, data, values) { 2 | var filtered = apply({ 3 | filter: values 4 | }, data); 5 | return filtered.length > 0; 6 | } 7 | 8 | some.deepFirst = false; 9 | export default some; -------------------------------------------------------------------------------- /lib/operations/index.js: -------------------------------------------------------------------------------- 1 | export * from './accessor'; 2 | export * from './arithmetic'; 3 | export * from './array'; 4 | export * from './logic'; 5 | export * from './misc'; 6 | export * from './numeric'; 7 | export * from './string'; -------------------------------------------------------------------------------- /lib/operations/logic/and.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | function and(apply, data, values) { 4 | var current; 5 | 6 | for (var i = 0; i < values.length; i++) { 7 | current = apply(values[i], data); 8 | 9 | if (!truthy(current)) { 10 | return current; 11 | } 12 | } 13 | 14 | return current; // Last 15 | } 16 | 17 | and.deepFirst = false; 18 | export default and; -------------------------------------------------------------------------------- /lib/operations/logic/equal.js: -------------------------------------------------------------------------------- 1 | function equal(a, b) { 2 | // eslint-disable-next-line eqeqeq 3 | return a == b; 4 | } 5 | 6 | equal.op = '=='; 7 | export default equal; -------------------------------------------------------------------------------- /lib/operations/logic/index.js: -------------------------------------------------------------------------------- 1 | export { default as and } from './and'; 2 | export { default as condition } from './condition'; 3 | export { default as equal } from './equal'; 4 | export { default as not } from './not'; 5 | export { default as notEqual } from './notEqual'; 6 | export { default as notnot } from './notnot'; 7 | export { default as or } from './or'; 8 | export { default as strictEqual } from './strictEqual'; 9 | export { default as strictNotEqual } from './strictNotEqual'; -------------------------------------------------------------------------------- /lib/operations/logic/not.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | function not(a) { 4 | return !truthy(a); 5 | } 6 | 7 | not.op = '!'; 8 | export default not; -------------------------------------------------------------------------------- /lib/operations/logic/notEqual.js: -------------------------------------------------------------------------------- 1 | function notEqual(a, b) { 2 | // eslint-disable-next-line eqeqeq 3 | return a != b; 4 | } 5 | 6 | notEqual.op = '!='; 7 | export default notEqual; -------------------------------------------------------------------------------- /lib/operations/logic/notnot.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | truthy.op = '!!'; 3 | export default truthy; -------------------------------------------------------------------------------- /lib/operations/logic/or.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | function or(apply, data, values) { 4 | var current; 5 | 6 | for (var i = 0; i < values.length; i++) { 7 | current = apply(values[i], data); 8 | 9 | if (truthy(current)) { 10 | return current; 11 | } 12 | } 13 | 14 | return current; // Last 15 | } 16 | 17 | or.deepFirst = false; 18 | export default or; -------------------------------------------------------------------------------- /lib/operations/logic/strictEqual.js: -------------------------------------------------------------------------------- 1 | function strictEqual(a, b) { 2 | return a === b; 3 | } 4 | 5 | strictEqual.op = '==='; 6 | export default strictEqual; -------------------------------------------------------------------------------- /lib/operations/logic/strictNotEqual.js: -------------------------------------------------------------------------------- 1 | function strictNotEqual(a, b) { 2 | return a !== b; 3 | } 4 | 5 | strictNotEqual.op = '!=='; 6 | export default strictNotEqual; -------------------------------------------------------------------------------- /lib/operations/misc/index.js: -------------------------------------------------------------------------------- 1 | export { default as indexOf } from './indexOf'; 2 | export { default as log } from './log'; 3 | export { default as method } from './method'; -------------------------------------------------------------------------------- /lib/operations/misc/indexOf.js: -------------------------------------------------------------------------------- 1 | function indexOf(a, b) { 2 | if (!b || typeof b.indexOf === 'undefined') return false; 3 | return b.indexOf(a) !== -1; 4 | } 5 | 6 | indexOf.op = 'in'; 7 | export default indexOf; -------------------------------------------------------------------------------- /lib/operations/misc/log.js: -------------------------------------------------------------------------------- 1 | function log(a) { 2 | // eslint-disable-next-line no-console 3 | console.log(a); 4 | return a; 5 | } 6 | 7 | export default log; -------------------------------------------------------------------------------- /lib/operations/misc/method.js: -------------------------------------------------------------------------------- 1 | function method(obj, methodName, args) { 2 | // eslint-disable-next-line prefer-spread 3 | return obj[methodName].apply(obj, args); 4 | } 5 | 6 | export default method; -------------------------------------------------------------------------------- /lib/operations/numeric/greater.js: -------------------------------------------------------------------------------- 1 | function greater(a, b) { 2 | return a > b; 3 | } 4 | 5 | greater.op = '>'; 6 | export default greater; -------------------------------------------------------------------------------- /lib/operations/numeric/greaterEqual.js: -------------------------------------------------------------------------------- 1 | function greaterEqual(a, b) { 2 | return a >= b; 3 | } 4 | 5 | greaterEqual.op = '>='; 6 | export default greaterEqual; -------------------------------------------------------------------------------- /lib/operations/numeric/index.js: -------------------------------------------------------------------------------- 1 | export { default as greater } from './greater'; 2 | export { default as greaterEqual } from './greaterEqual'; 3 | export { default as less } from './less'; 4 | export { default as lessEqual } from './lessEqual'; 5 | export { default as max } from './max'; 6 | export { default as min } from './min'; -------------------------------------------------------------------------------- /lib/operations/numeric/less.js: -------------------------------------------------------------------------------- 1 | function less(a, b, c) { 2 | return c === undefined ? a < b : a < b && b < c; 3 | } 4 | 5 | less.op = '<'; 6 | export default less; -------------------------------------------------------------------------------- /lib/operations/numeric/lessEqual.js: -------------------------------------------------------------------------------- 1 | function lessEqual(a, b, c) { 2 | return c === undefined ? a <= b : a <= b && b <= c; 3 | } 4 | 5 | lessEqual.op = '<='; 6 | export default lessEqual; -------------------------------------------------------------------------------- /lib/operations/numeric/max.js: -------------------------------------------------------------------------------- 1 | function max() { 2 | return Math.max.apply(Math, arguments); 3 | } 4 | 5 | export default max; -------------------------------------------------------------------------------- /lib/operations/numeric/min.js: -------------------------------------------------------------------------------- 1 | function min() { 2 | return Math.min.apply(Math, arguments); 3 | } 4 | 5 | export default min; -------------------------------------------------------------------------------- /lib/operations/string/cat.js: -------------------------------------------------------------------------------- 1 | function cat() { 2 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 3 | args[_key] = arguments[_key]; 4 | } 5 | 6 | return args.join(''); 7 | } 8 | 9 | export default cat; -------------------------------------------------------------------------------- /lib/operations/string/index.js: -------------------------------------------------------------------------------- 1 | export { default as cat } from './cat'; 2 | export { default as substr } from './substr'; -------------------------------------------------------------------------------- /lib/operations/string/substr.js: -------------------------------------------------------------------------------- 1 | function substr(source, start, end) { 2 | if (end < 0) { 3 | // JavaScript doesn't support negative end, this emulates PHP behavior 4 | var temp = String(source).substr(start); 5 | return temp.substr(0, temp.length + end); 6 | } 7 | 8 | return String(source).substr(start, end); 9 | } 10 | 11 | export default substr; -------------------------------------------------------------------------------- /schemas/common/all-types-wo-array.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/all-types-wo-array.json", 4 | 5 | "title": "All", 6 | "description": "Any valid JSON data type, except array primitive.", 7 | 8 | "oneOf": [ 9 | { "type": ["boolean", "null", "number", "string"] }, 10 | { "$ref": "http://jsonlogic.com/schemas/common/no-logic-object.json" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /schemas/common/all-types.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/all-types.json", 4 | 5 | "title": "All", 6 | "description": "Any valid JSON data type.", 7 | 8 | "oneOf": [ 9 | { "type": ["boolean", "null", "number", "string", "array"] }, 10 | { "$ref": "http://jsonlogic.com/schemas/common/no-logic-object.json" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /schemas/common/any-wo-array.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/any-wo-array.json", 4 | 5 | "title": "All", 6 | "description": "Any valid JSON Logic data source, except array primitive.", 7 | 8 | "oneOf": [ 9 | { "$ref": "http://jsonlogic.com/schemas/common/all-operators.json" }, 10 | 11 | { "$ref": "http://jsonlogic.com/schemas/common/all-types-wo-array.json" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /schemas/common/any.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/any.json", 4 | 5 | "title": "All", 6 | "description": "Any valid JSON Logic data source.", 7 | 8 | "oneOf": [ 9 | { "$ref": "http://jsonlogic.com/schemas/common/all-operators.json" }, 10 | 11 | { "$ref": "http://jsonlogic.com/schemas/common/all-types.json" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /schemas/common/binary-args.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/binary-args.json", 4 | 5 | "title": "Binary Arg", 6 | "description": "Up to two args of valid JSON Logic data source.", 7 | 8 | "oneOf": [ 9 | { 10 | "title": "Array", 11 | "description": "An array with one or two elements.", 12 | "type": "array", 13 | "minItems": 1, 14 | "maxItems": 2, 15 | "items": { 16 | "$ref": "http://jsonlogic.com/schemas/common/any.json" 17 | } 18 | }, 19 | { 20 | "$ref": "http://jsonlogic.com/schemas/common/any-wo-array.json", 21 | "title": "Single Arg", 22 | "description": "Note: binary operators can also take a single, non array argument:" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /schemas/common/one-or-more-args.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/one-or-more-args.json", 4 | 5 | "title": "1 or more args", 6 | "description": "With 1 or more arguments.", 7 | 8 | "oneOf": [ 9 | { 10 | "title": "Single Array", 11 | "description": "An array with 1 or more elements.", 12 | "type": "array", 13 | "items": { 14 | "$ref": "http://jsonlogic.com/schemas/common/any.json" 15 | } 16 | }, 17 | { 18 | "$ref": "http://jsonlogic.com/schemas/common/any-wo-array.json", 19 | "title": "Single Arg", 20 | "description": "Note: 1 or more operators can also take a single, non array argument:" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /schemas/common/pointer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/pointer.json", 4 | 5 | "title": "Pointer", 6 | "description": "Schema to access properties of an object or items of an array by index.", 7 | 8 | "oneOf": [ 9 | { 10 | "type": "string", 11 | "title": "Property", 12 | "description": "The key passed to var can use dot-notation to get the property of a property (to any depth you need):", 13 | "minLength": 1 14 | }, 15 | { 16 | "type": "integer", 17 | "title": "Index", 18 | "description": "You can also use the var operator to access an array by numeric index.", 19 | "minimum": 0 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /schemas/common/trinary-args.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/trinary-args.json", 4 | 5 | "title": "Trinary Args", 6 | "description": "Up to three args of valid JSON Logic data source.", 7 | 8 | "oneOf": [ 9 | { 10 | "title": "Array", 11 | "description": "An array with one or three elements.", 12 | "type": "array", 13 | "minItems": 1, 14 | "maxItems": 3, 15 | "items": { 16 | "$ref": "http://jsonlogic.com/schemas/common/any.json" 17 | } 18 | }, 19 | { 20 | "$ref": "http://jsonlogic.com/schemas/common/any-wo-array.json", 21 | "title": "Single Arg", 22 | "description": "Note: trinary operators can also take a single, non array argument:" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /schemas/common/unary-arg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/common/unary-arg.json", 4 | 5 | "title": "Unary Arg", 6 | "description": "Only one valid JSON Logic data source.", 7 | 8 | "oneOf": [ 9 | { 10 | "title": "Single Array", 11 | "description": "An array with just one element.", 12 | "type": "array", 13 | "minItems": 1, 14 | "maxItems": 1, 15 | "items": { 16 | "$ref": "http://jsonlogic.com/schemas/common/any.json" 17 | } 18 | }, 19 | { 20 | "$ref": "http://jsonlogic.com/schemas/common/any-wo-array.json", 21 | "title": "Single Arg", 22 | "description": "Note: unary operators can also take a single, non array argument:" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /schemas/json-logic.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/json-logic.json", 4 | 5 | "title": "JSON-Logic Schema", 6 | "description": "Build complex rules, serialize them as JSON, share them between front-end and back-end.", 7 | 8 | "$ref": "http://jsonlogic.com/schemas/common/any.json" 9 | } 10 | -------------------------------------------------------------------------------- /schemas/operators/accessor/missing.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/accessor/missing.json", 4 | 5 | "title": "missing", 6 | "description": "Takes an array of data keys to search for (same format as var). Returns an array of any keys that are missing from the data object, or an empty array.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["missing"], 10 | "properties": { 11 | "missing": { 12 | "$ref": "http://jsonlogic.com/schemas/common/var.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "missing": ["a", "b"] }, 17 | { "if": [ 18 | { "missing": ["a", "b"] }, 19 | "'a' and/or 'b' are missing", 20 | "OK to proceed" 21 | ]} 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /schemas/operators/accessor/variable.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/accessor/variable.json", 4 | 5 | "title": "var", 6 | "description": "Retrieve data from the provided data object.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["var"], 10 | "properties": { 11 | "var": { 12 | "$ref": "http://jsonlogic.com/schemas/common/var.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "var": ["a"] }, 17 | { "var": ["z", 26] }, 18 | { "var": "champ.name" }, 19 | { "var": 1 }, 20 | { "var": "" } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /schemas/operators/arithmetic/add.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/arithmetic/add.json", 4 | 5 | "title": "+", 6 | "description": "Addition. Because addition is associative, it happily take as many args as you want. Passing just one argument to + casts it to a number.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["+"], 11 | "properties": { 12 | "+": { 13 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "+": [4, 2] }, 18 | { "+": [2, 2, 2, 2, 2] }, 19 | { "+": "3.14" } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /schemas/operators/arithmetic/divide.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/arithmetic/divide.json", 4 | 5 | "title": "/", 6 | "description": "Division.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["/"], 11 | "properties": { 12 | "/": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "/": [4, 2] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /schemas/operators/arithmetic/modulo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/arithmetic/modulo.json", 4 | 5 | "title": "%", 6 | "description": "Module. Finds the remainder after the first argument is divided by the second argument.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["%"], 11 | "properties": { 12 | "%": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "%": [101, 2] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /schemas/operators/arithmetic/multiply.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/arithmetic/multiply.json", 4 | 5 | "title": "*", 6 | "description": "Multiplication. Because multiplication is associative, it happily take as many args as you want.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["*"], 11 | "properties": { 12 | "*": { 13 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "*": [4, 2] }, 18 | { "*": [2, 2, 2, 2, 2] } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /schemas/operators/arithmetic/subtract.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/arithmetic/subtract.json", 4 | 5 | "title": "-", 6 | "description": "Subtraction. Passing just one argument to - returns its arithmetic negative (additive inverse).", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["-"], 11 | "properties": { 12 | "-": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "-": [4, 2] }, 18 | { "-": 2 }, 19 | { "-": -2 } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /schemas/operators/array/all.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/array/all.json", 4 | 5 | "title": "all", 6 | "description": "These operations take an array, and perform a test on each member of that array.\nThe most interesting part of these operations is that inside the test code, var operations are relative to the array element being tested.\nIt can be useful to use {\"var\":\"\"} to get the entire array element within the test.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["all"], 10 | "properties": { 11 | "all": { 12 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "all": [ [1, 2, 3], { ">": [{ "var": "" }, 0] } ] } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /schemas/operators/array/filter.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/array/filter.json", 4 | 5 | "title": "filter", 6 | "description": "You can use filter to keep only elements of the array that pass a test. Note, that inside the logic being used to map, var operations are relative to the array element being worked on.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["filter"], 10 | "properties": { 11 | "filter": { 12 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "filter": [ 17 | { "var": "integers" }, 18 | { "%": [{ "var": "" }, 2] } 19 | ]} 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /schemas/operators/array/map.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/array/map.json", 4 | 5 | "title": "map", 6 | "description": "You can use map to perform an action on every member of an array. Note, that inside the logic being used to map, var operations are relative to the array element being worked on.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["map"], 10 | "properties": { 11 | "map": { 12 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "map": [ 17 | { "var": "integers" }, 18 | { "*": [{ "var": "" }, 2] } 19 | ]} 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /schemas/operators/array/merge.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/array/merge.json", 4 | 5 | "title": "merge", 6 | "description": "Takes one or more arrays, and merges them into one array. If arguments aren’t arrays, they get cast to arrays.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["merge"], 10 | "properties": { 11 | "merge": { 12 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "merge": [ [1,2], [3,4] ] }, 17 | { "merge": [ 1, 2, [3,4] ] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /schemas/operators/array/none.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/array/none.json", 4 | 5 | "title": "none", 6 | "description": "These operations take an array, and perform a test on each member of that array.\nThe most interesting part of these operations is that inside the test code, var operations are relative to the array element being tested.\nIt can be useful to use {\"var\":\"\"} to get the entire array element within the test.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["none"], 10 | "properties": { 11 | "none": { 12 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "none": [ [-3, -2, -1], { ">": [{ "var": "" }, 0] } ]} 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /schemas/operators/logic/and.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/logic/and.json", 4 | 5 | "title": "and", 6 | "description": "and can be used for simple boolean tests, with 1 or more arguments. At a more sophisticated level, and returns the first falsy argument, or the last argument.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["and"], 11 | "properties": { 12 | "and": { 13 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "and": [true, true] }, 18 | { "and": [true, false] }, 19 | { "and": [true, "a", 3] }, 20 | { "and": [true, "", 3] } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /schemas/operators/logic/equal.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/logic/equal.json", 4 | 5 | "title": "Equal", 6 | "description": "Tests equality, with type coercion. Requires two arguments.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["=="], 11 | "properties": { 12 | "==": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "==": [1, 1] }, 18 | { "==": [1, "1"] }, 19 | { "==": [0, false] } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /schemas/operators/logic/not.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/logic/not.json", 4 | 5 | "title": "!", 6 | "description": "Logical negation (“not”). Takes just one argument.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["!"], 11 | "properties": { 12 | "!": { 13 | "$ref": "http://jsonlogic.com/schemas/common/unary-arg.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "!": [true] }, 18 | { "!": true } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /schemas/operators/logic/notEqual.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/logic/notEqual.json", 4 | 5 | "title": "Not-Equal", 6 | "description": "Tests not-equal, with type coercion. Requires two arguments.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["!="], 11 | "properties": { 12 | "!=": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "!=": [1, 2] }, 18 | { "!=": [1, "1"] } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /schemas/operators/logic/notnot.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/logic/notnot.json", 4 | 5 | "title": "!!", 6 | "description": "Double negation, or “cast to a boolean.” Takes a single argument.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["!!"], 11 | "properties": { 12 | "!!": { 13 | "$ref": "http://jsonlogic.com/schemas/common/unary-arg.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "!!": [ [] ] }, 18 | { "!!": ["0"] } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /schemas/operators/logic/or.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/logic/or.json", 4 | 5 | "title": "or", 6 | "description": "or can be used for simple boolean tests, with 1 or more arguments. At a more sophisticated level, or returns the first truthy argument, or the last argument.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["or"], 11 | "properties": { 12 | "or": { 13 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "or": [true, false] }, 18 | { "or": [false, true] }, 19 | { "or": [false, "a"] }, 20 | { "or": [false, 0, "a"] } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /schemas/operators/logic/strictEqual.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/logic/strictEqual.json", 4 | 5 | "title": "Strict Equal", 6 | "description": "Tests strict equality. Requires two arguments.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["==="], 11 | "properties": { 12 | "===": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "===": [1, 1] }, 18 | { "===": [1, "1"] } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /schemas/operators/logic/strictNotEqual.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/logic/strictNotEqual.json", 4 | 5 | "title": "Strict Not-Equal", 6 | "description": "Tests strict not-equal. Requires two arguments.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["!=="], 11 | "properties": { 12 | "!==": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "!==": [1, 2] }, 18 | { "!==": [1, "1"] } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /schemas/operators/misc/in.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/misc/in.json", 4 | 5 | "title": "in", 6 | "description": "If the second argument is an array, tests that the first argument is a member of the array: {\"in\":[ \"Ringo\", [\"John\", \"Paul\", \"George\", \"Ringo\"] ]}.\nIf the second argument is a string, tests that the first argument is a substring: {\"in\":[\"Spring\", \"Springfield\"]}.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["in"], 10 | "properties": { 11 | "in": { 12 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "in": ["Spring", "Springfield"] } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /schemas/operators/misc/log.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/misc/log.json", 4 | 5 | "title": "log", 6 | "description": "Logs the first value to console, then passes it through unmodified.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["log"], 10 | "properties": { 11 | "log": { 12 | "$ref": "http://jsonlogic.com/schemas/common/any.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "log": "apple" } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /schemas/operators/misc/method.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/misc/method.json", 4 | 5 | "title": "method", 6 | "description": "If your rule needs to call a method on an object, you can use the built-in method operation.\n You can also pass an array of arguments into the method.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["method"], 10 | "properties": { 11 | "method": { 12 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "method": [{"var":"today"}, "getDay"] }, 17 | { "method": ["automaton", "slice", [ 2, 8 ]] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /schemas/operators/numeric/greater.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/numeric/greater.json", 4 | 5 | "title": ">", 6 | "description": "Greater than.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": [">"], 11 | "properties": { 12 | ">": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { ">": [2, 1] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /schemas/operators/numeric/greaterEqual.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/numeric/greaterEqual.json", 4 | 5 | "title": ">=", 6 | "description": "Greater than or equal to.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": [">="], 11 | "properties": { 12 | ">=": { 13 | "$ref": "http://jsonlogic.com/schemas/common/binary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { ">=": [1, 1] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /schemas/operators/numeric/less.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/numeric/less.json", 4 | 5 | "title": "<", 6 | "description": "Less than. You can use a special case of < to test that one value is exclusively between two others.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["<"], 11 | "properties": { 12 | "<": { 13 | "$ref": "http://jsonlogic.com/schemas/common/trinary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "<": [1, 2] }, 18 | { "<": [1, 2, 3] }, 19 | { "<": [0, {"var":"temp"}, 100] } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /schemas/operators/numeric/lessEqual.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/numeric/lessEqual.json", 4 | 5 | "title": "<=", 6 | "description": "Less than or equal to. You can use a special case of <= to test that one value is inclusively between two others.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["<="], 11 | "properties": { 12 | "<=": { 13 | "$ref": "http://jsonlogic.com/schemas/common/trinary-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "<=": [1, 1] }, 18 | { "<=": [1, 2, 3] }, 19 | { "<=": [0, {"var":"temp"}, 100] } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /schemas/operators/numeric/max.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/numeric/max.json", 4 | 5 | "title": "max", 6 | "description": "Return the maximum from a list of values.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["max"], 11 | "properties": { 12 | "max": { 13 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "max": [1,2,3] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /schemas/operators/numeric/min.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/numeric/min.json", 4 | 5 | "title": "min", 6 | "description": "Return the minimum from a list of values.", 7 | 8 | "type": "object", 9 | "additionalProperties": false, 10 | "required": ["min"], 11 | "properties": { 12 | "min": { 13 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 14 | } 15 | }, 16 | "examples": [ 17 | { "min": [1,2,3] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /schemas/operators/string/cat.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://jsonlogic.com/schemas/operators/string/cat.json", 4 | 5 | "title": "cat", 6 | "description": "Concatenate all the supplied arguments. Note that this is not a join or implode operation, there is no “glue” string.", 7 | "type": "object", 8 | "additionalProperties": false, 9 | "required": ["cat"], 10 | "properties": { 11 | "cat": { 12 | "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json" 13 | } 14 | }, 15 | "examples": [ 16 | { "cat": ["I love", " pie"] }, 17 | { "cat": ["I love ", {"var":"filling"}, " pie"] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/helpers/arrayUnique.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Return an array that contains no duplicates (original not modified) 3 | * @param {array} array Original reference array 4 | * @return {array} New array with no duplicates 5 | */ 6 | function arrayUnique(array) { 7 | const a = []; 8 | for (let i = 0, l = array.length; i < l; i++) { 9 | if (a.indexOf(array[i]) === -1) { 10 | a.push(array[i]); 11 | } 12 | } 13 | return a; 14 | } 15 | 16 | export default arrayUnique; 17 | -------------------------------------------------------------------------------- /src/helpers/get_operator.js: -------------------------------------------------------------------------------- 1 | function get_operator(logic) { 2 | return Object.keys(logic)[0]; 3 | } 4 | 5 | export default get_operator; 6 | -------------------------------------------------------------------------------- /src/helpers/get_values.js: -------------------------------------------------------------------------------- 1 | import get_operator from './get_operator'; 2 | 3 | function get_values(logic) { 4 | return logic[get_operator(logic)]; 5 | } 6 | 7 | export default get_values; 8 | -------------------------------------------------------------------------------- /src/helpers/isArray.js: -------------------------------------------------------------------------------- 1 | export default Array.isArray; 2 | -------------------------------------------------------------------------------- /src/helpers/is_logic.js: -------------------------------------------------------------------------------- 1 | import isArray from './isArray'; 2 | 3 | function is_logic(logic) { 4 | return ( 5 | typeof logic === 'object' && // An object 6 | logic !== null && // but not null 7 | !isArray(logic) && // and not an array 8 | Object.keys(logic).length === 1 // with exactly one key 9 | ); 10 | } 11 | 12 | export default is_logic; 13 | -------------------------------------------------------------------------------- /src/helpers/truthy.js: -------------------------------------------------------------------------------- 1 | import isArray from './isArray'; 2 | 3 | /* 4 | This helper will defer to the JsonLogic spec as a tie-breaker when different language interpreters define different behavior for the truthiness of primitives. E.g., PHP considers empty arrays to be falsy, but Javascript considers them to be truthy. JsonLogic, as an ecosystem, needs one consistent answer. 5 | 6 | Spec and rationale here: http://jsonlogic.com/truthy 7 | */ 8 | function truthy(value) { 9 | if (isArray(value) && value.length === 0) { 10 | return false; 11 | } 12 | 13 | return !!value; 14 | } 15 | 16 | export default truthy; 17 | -------------------------------------------------------------------------------- /src/helpers/uses_data.js: -------------------------------------------------------------------------------- 1 | import isArray from './isArray'; 2 | import is_logic from './is_logic'; 3 | import get_operator from './get_operator'; 4 | import arrayUnique from './arrayUnique'; 5 | 6 | function uses_data(logic) { 7 | const collection = []; 8 | 9 | if (is_logic(logic)) { 10 | const op = get_operator(logic); 11 | let values = logic[op]; 12 | 13 | if (!isArray(values)) { 14 | values = [values]; 15 | } 16 | 17 | if (op === 'var') { 18 | // This doesn't cover the case where the arg to var is itself a rule. 19 | collection.push(values[0]); 20 | } else { 21 | // Recursion! 22 | values.forEach(val => { 23 | collection.push(...uses_data(val)); 24 | }); 25 | } 26 | } 27 | 28 | return arrayUnique(collection); 29 | } 30 | 31 | export default uses_data; 32 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import createJsonLogic from './createJsonLogic'; 2 | import * as operations from './operations'; 3 | import is_logic from './helpers/is_logic'; 4 | import truthy from './helpers/truthy'; 5 | import get_operator from './helpers/get_operator'; 6 | import get_values from './helpers/get_values'; 7 | import uses_data from './helpers/uses_data'; 8 | import rule_like from './helpers/rule_like'; 9 | 10 | const jsonLogic = createJsonLogic(operations); 11 | 12 | // restore original public API 13 | jsonLogic.is_logic = is_logic; 14 | jsonLogic.truthy = truthy; 15 | jsonLogic.get_operator = get_operator; 16 | jsonLogic.get_values = get_values; 17 | jsonLogic.uses_data = uses_data; 18 | jsonLogic.rule_like = rule_like; 19 | 20 | export default jsonLogic; 21 | -------------------------------------------------------------------------------- /src/operations/accessor/index.js: -------------------------------------------------------------------------------- 1 | export { default as variable } from './variable'; 2 | export { default as missing } from './missing'; 3 | export { default as missing_some } from './missing_some'; 4 | -------------------------------------------------------------------------------- /src/operations/accessor/missing.js: -------------------------------------------------------------------------------- 1 | import isArray from '../../helpers/isArray'; 2 | 3 | function missing(apply, ...args) { 4 | /* 5 | Missing can receive many keys as many arguments, like {"missing:[1,2]} 6 | Missing can also receive *one* argument that is an array of keys, 7 | which typically happens if it's actually acting on the output of another command 8 | (like 'if' or 'merge') 9 | */ 10 | 11 | const are_missing = []; 12 | const keys = isArray(args[0]) ? args[0] : args; 13 | 14 | for (let i = 0; i < keys.length; i++) { 15 | const key = keys[i]; 16 | const value = apply({ var: key }, this); 17 | if (value === null || value === '') { 18 | are_missing.push(key); 19 | } 20 | } 21 | 22 | return are_missing; 23 | } 24 | 25 | missing.withApply = true; 26 | 27 | export default missing; 28 | -------------------------------------------------------------------------------- /src/operations/accessor/missing_some.js: -------------------------------------------------------------------------------- 1 | function missing_some(apply, need_count, options) { 2 | // missing_some takes two arguments, how many (minimum) items must be present, and an array of keys (just like 'missing') to check for presence. 3 | const are_missing = apply({ missing: options }, this); 4 | 5 | if (options.length - are_missing.length >= need_count) { 6 | return []; 7 | } 8 | return are_missing; 9 | } 10 | 11 | missing_some.withApply = true; 12 | 13 | export default missing_some; 14 | -------------------------------------------------------------------------------- /src/operations/accessor/variable.js: -------------------------------------------------------------------------------- 1 | function variable(a, b) { 2 | const not_found = b === undefined ? null : b; 3 | let data = this; 4 | 5 | if (typeof a === 'undefined' || a === '' || a === null) { 6 | return data; 7 | } 8 | 9 | const sub_props = String(a).split('.'); 10 | 11 | for (let i = 0; i < sub_props.length; i++) { 12 | if (data === null) { 13 | return not_found; 14 | } 15 | // Descending into data 16 | data = data[sub_props[i]]; 17 | if (data === undefined) { 18 | return not_found; 19 | } 20 | } 21 | 22 | return data; 23 | } 24 | 25 | variable.op = 'var'; 26 | 27 | export default variable; 28 | -------------------------------------------------------------------------------- /src/operations/arithmetic/add.js: -------------------------------------------------------------------------------- 1 | function add(...args) { 2 | return args.reduce((a, b) => parseFloat(a, 10) + parseFloat(b, 10), 0); 3 | } 4 | 5 | add.op = '+'; 6 | 7 | export default add; 8 | -------------------------------------------------------------------------------- /src/operations/arithmetic/divide.js: -------------------------------------------------------------------------------- 1 | function divide(a, b) { 2 | return a / b; 3 | } 4 | 5 | divide.op = '/'; 6 | 7 | export default divide; 8 | -------------------------------------------------------------------------------- /src/operations/arithmetic/index.js: -------------------------------------------------------------------------------- 1 | export { default as add } from './add'; 2 | export { default as divide } from './divide'; 3 | export { default as modulo } from './modulo'; 4 | export { default as multiply } from './multiply'; 5 | export { default as subtract } from './subtract'; 6 | -------------------------------------------------------------------------------- /src/operations/arithmetic/modulo.js: -------------------------------------------------------------------------------- 1 | function modulo(a, b) { 2 | return a % b; 3 | } 4 | 5 | modulo.op = '%'; 6 | 7 | export default modulo; 8 | -------------------------------------------------------------------------------- /src/operations/arithmetic/multiply.js: -------------------------------------------------------------------------------- 1 | function multiply(...args) { 2 | return args.reduce((a, b) => parseFloat(a, 10) * parseFloat(b, 10), 1); 3 | } 4 | 5 | multiply.op = '*'; 6 | 7 | export default multiply; 8 | -------------------------------------------------------------------------------- /src/operations/arithmetic/subtract.js: -------------------------------------------------------------------------------- 1 | function subtract(a, b) { 2 | if (b === undefined) { 3 | return -a; 4 | } 5 | return a - b; 6 | } 7 | 8 | subtract.op = '-'; 9 | 10 | export default subtract; 11 | -------------------------------------------------------------------------------- /src/operations/array/all.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | function all(apply, data, values) { 4 | const scopedData = apply(values[0], data); 5 | const scopedLogic = values[1]; 6 | // All of an empty set is false. Note, some and none have correct fallback after the for loop 7 | if (!scopedData.length) { 8 | return false; 9 | } 10 | for (let i = 0; i < scopedData.length; i += 1) { 11 | if (!truthy(apply(scopedLogic, scopedData[i]))) { 12 | return false; // First falsy, short circuit 13 | } 14 | } 15 | return true; // All were truthy 16 | } 17 | 18 | all.deepFirst = false; 19 | 20 | export default all; 21 | -------------------------------------------------------------------------------- /src/operations/array/filter.js: -------------------------------------------------------------------------------- 1 | import isArray from '../../helpers/isArray'; 2 | import truthy from '../../helpers/truthy'; 3 | 4 | function filter(apply, data, values) { 5 | const scopedData = apply(values[0], data); 6 | const scopedLogic = values[1]; 7 | 8 | if (!isArray(scopedData)) { 9 | return []; 10 | } 11 | // Return only the elements from the array in the first argument, 12 | // that return truthy when passed to the logic in the second argument. 13 | // For parity with JavaScript, reindex the returned array 14 | return scopedData.filter(datum => truthy(apply(scopedLogic, datum))); 15 | } 16 | 17 | filter.deepFirst = false; 18 | 19 | export default filter; 20 | -------------------------------------------------------------------------------- /src/operations/array/index.js: -------------------------------------------------------------------------------- 1 | export { default as all } from './all'; 2 | export { default as filter } from './filter'; 3 | export { default as map } from './map'; 4 | export { default as merge } from './merge'; 5 | export { default as none } from './none'; 6 | export { default as reduce } from './reduce'; 7 | export { default as some } from './some'; 8 | -------------------------------------------------------------------------------- /src/operations/array/map.js: -------------------------------------------------------------------------------- 1 | import isArray from '../../helpers/isArray'; 2 | 3 | function map(apply, data, values) { 4 | const scopedData = apply(values[0], data); 5 | const scopedLogic = values[1]; 6 | 7 | if (!isArray(scopedData)) { 8 | return []; 9 | } 10 | 11 | return scopedData.map(datum => apply(scopedLogic, datum)); 12 | } 13 | 14 | map.deepFirst = false; 15 | 16 | export default map; 17 | -------------------------------------------------------------------------------- /src/operations/array/merge.js: -------------------------------------------------------------------------------- 1 | function merge(...args) { 2 | return args.reduce((a, b) => a.concat(b), []); 3 | } 4 | 5 | export default merge; 6 | -------------------------------------------------------------------------------- /src/operations/array/none.js: -------------------------------------------------------------------------------- 1 | function none(apply, data, values) { 2 | const filtered = apply({ filter: values }, data); 3 | 4 | return filtered.length === 0; 5 | } 6 | 7 | none.deepFirst = false; 8 | 9 | export default none; 10 | -------------------------------------------------------------------------------- /src/operations/array/reduce.js: -------------------------------------------------------------------------------- 1 | import isArray from '../../helpers/isArray'; 2 | 3 | function reduce(apply, data, values) { 4 | const scopedData = apply(values[0], data); 5 | const scopedLogic = values[1]; 6 | const initial = typeof values[2] !== 'undefined' ? values[2] : null; 7 | 8 | if (!isArray(scopedData)) { 9 | return initial; 10 | } 11 | 12 | return scopedData.reduce( 13 | (accumulator, current) => apply(scopedLogic, { current, accumulator }), 14 | initial 15 | ); 16 | } 17 | 18 | reduce.deepFirst = false; 19 | 20 | export default reduce; 21 | -------------------------------------------------------------------------------- /src/operations/array/some.js: -------------------------------------------------------------------------------- 1 | function some(apply, data, values) { 2 | const filtered = apply({ filter: values }, data); 3 | 4 | return filtered.length > 0; 5 | } 6 | 7 | some.deepFirst = false; 8 | 9 | export default some; 10 | -------------------------------------------------------------------------------- /src/operations/index.js: -------------------------------------------------------------------------------- 1 | export * from './accessor'; 2 | export * from './arithmetic'; 3 | export * from './array'; 4 | export * from './logic'; 5 | export * from './misc'; 6 | export * from './numeric'; 7 | export * from './string'; 8 | -------------------------------------------------------------------------------- /src/operations/logic/and.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | function and(apply, data, values) { 4 | let current; 5 | 6 | for (let i = 0; i < values.length; i++) { 7 | current = apply(values[i], data); 8 | if (!truthy(current)) { 9 | return current; 10 | } 11 | } 12 | return current; // Last 13 | } 14 | 15 | and.deepFirst = false; 16 | 17 | export default and; 18 | -------------------------------------------------------------------------------- /src/operations/logic/equal.js: -------------------------------------------------------------------------------- 1 | function equal(a, b) { 2 | // eslint-disable-next-line eqeqeq 3 | return a == b; 4 | } 5 | 6 | equal.op = '=='; 7 | 8 | export default equal; 9 | -------------------------------------------------------------------------------- /src/operations/logic/index.js: -------------------------------------------------------------------------------- 1 | export { default as and } from './and'; 2 | export { default as condition } from './condition'; 3 | export { default as equal } from './equal'; 4 | export { default as not } from './not'; 5 | export { default as notEqual } from './notEqual'; 6 | export { default as notnot } from './notnot'; 7 | export { default as or } from './or'; 8 | export { default as strictEqual } from './strictEqual'; 9 | export { default as strictNotEqual } from './strictNotEqual'; 10 | -------------------------------------------------------------------------------- /src/operations/logic/not.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | function not(a) { 4 | return !truthy(a); 5 | } 6 | 7 | not.op = '!'; 8 | 9 | export default not; 10 | -------------------------------------------------------------------------------- /src/operations/logic/notEqual.js: -------------------------------------------------------------------------------- 1 | function notEqual(a, b) { 2 | // eslint-disable-next-line eqeqeq 3 | return a != b; 4 | } 5 | 6 | notEqual.op = '!='; 7 | 8 | export default notEqual; 9 | -------------------------------------------------------------------------------- /src/operations/logic/notnot.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | truthy.op = '!!'; 4 | 5 | export default truthy; 6 | -------------------------------------------------------------------------------- /src/operations/logic/or.js: -------------------------------------------------------------------------------- 1 | import truthy from '../../helpers/truthy'; 2 | 3 | function or(apply, data, values) { 4 | let current; 5 | 6 | for (let i = 0; i < values.length; i++) { 7 | current = apply(values[i], data); 8 | if (truthy(current)) { 9 | return current; 10 | } 11 | } 12 | return current; // Last 13 | } 14 | 15 | or.deepFirst = false; 16 | 17 | export default or; 18 | -------------------------------------------------------------------------------- /src/operations/logic/strictEqual.js: -------------------------------------------------------------------------------- 1 | function strictEqual(a, b) { 2 | return a === b; 3 | } 4 | 5 | strictEqual.op = '==='; 6 | 7 | export default strictEqual; 8 | -------------------------------------------------------------------------------- /src/operations/logic/strictNotEqual.js: -------------------------------------------------------------------------------- 1 | function strictNotEqual(a, b) { 2 | return a !== b; 3 | } 4 | 5 | strictNotEqual.op = '!=='; 6 | 7 | export default strictNotEqual; 8 | -------------------------------------------------------------------------------- /src/operations/misc/index.js: -------------------------------------------------------------------------------- 1 | export { default as indexOf } from './indexOf'; 2 | export { default as log } from './log'; 3 | export { default as method } from './method'; 4 | -------------------------------------------------------------------------------- /src/operations/misc/indexOf.js: -------------------------------------------------------------------------------- 1 | function indexOf(a, b) { 2 | if (!b || typeof b.indexOf === 'undefined') return false; 3 | return b.indexOf(a) !== -1; 4 | } 5 | 6 | indexOf.op = 'in'; 7 | 8 | export default indexOf; 9 | -------------------------------------------------------------------------------- /src/operations/misc/log.js: -------------------------------------------------------------------------------- 1 | function log(a) { 2 | // eslint-disable-next-line no-console 3 | console.log(a); 4 | 5 | return a; 6 | } 7 | 8 | export default log; 9 | -------------------------------------------------------------------------------- /src/operations/misc/method.js: -------------------------------------------------------------------------------- 1 | function method(obj, methodName, args) { 2 | // eslint-disable-next-line prefer-spread 3 | return obj[methodName].apply(obj, args); 4 | } 5 | 6 | export default method; 7 | -------------------------------------------------------------------------------- /src/operations/numeric/greater.js: -------------------------------------------------------------------------------- 1 | function greater(a, b) { 2 | return a > b; 3 | } 4 | 5 | greater.op = '>'; 6 | 7 | export default greater; 8 | -------------------------------------------------------------------------------- /src/operations/numeric/greaterEqual.js: -------------------------------------------------------------------------------- 1 | function greaterEqual(a, b) { 2 | return a >= b; 3 | } 4 | 5 | greaterEqual.op = '>='; 6 | 7 | export default greaterEqual; 8 | -------------------------------------------------------------------------------- /src/operations/numeric/index.js: -------------------------------------------------------------------------------- 1 | export { default as greater } from './greater'; 2 | export { default as greaterEqual } from './greaterEqual'; 3 | export { default as less } from './less'; 4 | export { default as lessEqual } from './lessEqual'; 5 | export { default as max } from './max'; 6 | export { default as min } from './min'; 7 | -------------------------------------------------------------------------------- /src/operations/numeric/less.js: -------------------------------------------------------------------------------- 1 | function less(a, b, c) { 2 | return c === undefined ? a < b : a < b && b < c; 3 | } 4 | 5 | less.op = '<'; 6 | 7 | export default less; 8 | -------------------------------------------------------------------------------- /src/operations/numeric/lessEqual.js: -------------------------------------------------------------------------------- 1 | function lessEqual(a, b, c) { 2 | return c === undefined ? a <= b : a <= b && b <= c; 3 | } 4 | 5 | lessEqual.op = '<='; 6 | 7 | export default lessEqual; 8 | -------------------------------------------------------------------------------- /src/operations/numeric/max.js: -------------------------------------------------------------------------------- 1 | function max(...args) { 2 | return Math.max(...args); 3 | } 4 | 5 | export default max; 6 | -------------------------------------------------------------------------------- /src/operations/numeric/min.js: -------------------------------------------------------------------------------- 1 | function min(...args) { 2 | return Math.min(...args); 3 | } 4 | 5 | export default min; 6 | -------------------------------------------------------------------------------- /src/operations/string/cat.js: -------------------------------------------------------------------------------- 1 | function cat(...args) { 2 | return args.join(''); 3 | } 4 | 5 | export default cat; 6 | -------------------------------------------------------------------------------- /src/operations/string/index.js: -------------------------------------------------------------------------------- 1 | export { default as cat } from './cat'; 2 | export { default as substr } from './substr'; 3 | -------------------------------------------------------------------------------- /src/operations/string/substr.js: -------------------------------------------------------------------------------- 1 | function substr(source, start, end) { 2 | if (end < 0) { 3 | // JavaScript doesn't support negative end, this emulates PHP behavior 4 | const temp = String(source).substr(start); 5 | return temp.substr(0, temp.length + end); 6 | } 7 | return String(source).substr(start, end); 8 | } 9 | 10 | export default substr; 11 | --------------------------------------------------------------------------------