HEX
Server: Apache/2.4.18 (Ubuntu)
System: Linux ubuntu 7.0.5-x86_64-linode173 #1 SMP PREEMPT_DYNAMIC Fri May 8 10:12:05 EDT 2026 x86_64
User: root (0)
PHP: 7.2.28-1+ubuntu16.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: //opt/code/node_modules/webpack/node_modules/ajv-keywords/package.json
{
  "name": "ajv-keywords",
  "version": "1.5.1",
  "description": "Custom JSON-Schema keywords for ajv validator",
  "main": "index.js",
  "scripts": {
    "build": "node node_modules/ajv/scripts/compile-dots.js node_modules/ajv/lib keywords",
    "prepublish": "npm run build",
    "test": "npm run build && npm run eslint && npm run test-cov",
    "eslint": "eslint index.js keywords/*.js",
    "test-spec": "mocha spec/*.spec.js -R spec",
    "test-cov": "istanbul cover -x 'spec/**' node_modules/mocha/bin/_mocha -- spec/*.spec.js -R spec"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/epoberezkin/ajv-keywords.git"
  },
  "keywords": [
    "JSON-Schema",
    "ajv",
    "keywords"
  ],
  "files": [
    "index.js",
    "keywords"
  ],
  "author": {
    "name": "Evgeny Poberezkin"
  },
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/epoberezkin/ajv-keywords/issues"
  },
  "homepage": "https://github.com/epoberezkin/ajv-keywords#readme",
  "peerDependencies": {
    "ajv": ">=4.10.0"
  },
  "devDependencies": {
    "ajv": "^4.10.0",
    "ajv-pack": "^0.2.0",
    "chai": "^3.5.0",
    "coveralls": "^2.11.9",
    "dot": "^1.1.1",
    "eslint": "^3.6.0",
    "glob": "^7.1.1",
    "istanbul": "^0.4.3",
    "js-beautify": "^1.6.4",
    "json-schema-test": "^1.2.1",
    "mocha": "^3.0.2",
    "pre-commit": "^1.1.3",
    "uuid": "^3.0.1"
  },
  "readme": "# ajv-keywords\n\nCustom JSON-Schema keywords for [ajv](https://github.com/epoberezkin/ajv) validator\n\n[![Build Status](https://travis-ci.org/epoberezkin/ajv-keywords.svg?branch=master)](https://travis-ci.org/epoberezkin/ajv-keywords)\n[![npm version](https://badge.fury.io/js/ajv-keywords.svg)](https://www.npmjs.com/package/ajv-keywords)\n[![npm downloads](https://img.shields.io/npm/dm/ajv-keywords.svg)](https://www.npmjs.com/package/ajv-keywords)\n[![Coverage Status](https://coveralls.io/repos/github/epoberezkin/ajv-keywords/badge.svg?branch=master)](https://coveralls.io/github/epoberezkin/ajv-keywords?branch=master)\n\n\n## Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [Keywords](#keywords)\n  - [typeof](#typeof)\n  - [instanceof](#instanceof)\n  - [range and exclusiveRange](#range-and-exclusiverange)\n  - [propertyNames](#propertynames)\n  - [if/then/else](#ifthenelse)\n  - [prohibited](#prohibited)\n  - [deepProperties](#deepproperties)\n  - [deepRequired](#deeprequired)\n  - [regexp](#regexp)\n  - [dynamicDefaults](#dynamicdefaults)\n- [License](#license)\n\n\n## Install\n\n```\nnpm install ajv-keywords\n```\n\n\n## Usage\n\nTo add all available keywords:\n\n```javascript\nvar Ajv = require('ajv');\nvar ajv = new Ajv;\nrequire('ajv-keywords')(ajv);\n\najv.validate({ instanceof: 'RegExp' }, /.*/); // true\najv.validate({ instanceof: 'RegExp' }, '.*'); // false\n```\n\nTo add a single keyword:\n\n```javascript\nrequire('ajv-keywords')(ajv, 'instanceof');\n```\n\nTo add multiple keywords:\n\n```javascript\nrequire('ajv-keywords')(ajv, ['typeof', 'instanceof']);\n```\n\nTo add a single keyword in browser (to avoid adding unused code):\n\n```javascript\nrequire('ajv-keywords/keywords/instanceof')(ajv);\n```\n\n\n## Keywords\n\n### `typeof`\n\nBased on JavaScript `typeof` operation.\n\nThe value of the keyword should be a string (`\"undefined\"`, `\"string\"`, `\"number\"`, `\"object\"`, `\"function\"`, `\"boolean\"` or `\"symbol\"`) or array of strings.\n\nTo pass validation the result of `typeof` operation on the value should be equal to the string (or one of the strings in the array).\n\n```\najv.validate({ typeof: 'undefined' }, undefined); // true\najv.validate({ typeof: 'undefined' }, null); // false\najv.validate({ typeof: ['undefined', 'object'] }, null); // true\n```\n\n\n### `instanceof`\n\nBased on JavaScript `instanceof` operation.\n\nThe value of the keyword should be a string (`\"Object\"`, `\"Array\"`, `\"Function\"`, `\"Number\"`, `\"String\"`, `\"Date\"`, `\"RegExp\"` or `\"Buffer\"`) or array of strings.\n\nTo pass validation the result of `data instanceof ...` operation on the value should be true:\n\n```\najv.validate({ instanceof: 'Array' }, []); // true\najv.validate({ instanceof: 'Array' }, {}); // false\najv.validate({ instanceof: ['Array', 'Function'] }, funciton(){}); // true\n```\n\nYou can add your own constructor function to be recognised by this keyword:\n\n```javascript\nfunction MyClass() {}\nvar instanceofDefinition = require('ajv-keywords').get('instanceof').definition;\n// or require('ajv-keywords/keywords/instanceof').definition;\ninstanceofDefinition.CONSTRUCTORS.MyClass = MyClass;\n\najv.validate({ instanceof: 'MyClass' }, new MyClass); // true\n```\n\n\n### `range` and `exclusiveRange`\n\nSyntax sugar for the combination of minimum and maximum keywords, also fails schema compilation if there are no numbers in the range.\n\nThe value of this keyword must be the array consisting of two numbers, the second must be greater or equal than the first one.\n\nIf the validated value is not a number the validation passes, otherwise to pass validation the value should be greater (or equal) than the first number and smaller (or equal) than the second number in the array. If `exclusiveRange` keyword is present in the same schema and its value is true, the validated value must not be equal to the range boundaries.\n\n```javascript\nvar schema = { range: [1, 3] };\najv.validate(schema, 1); // true\najv.validate(schema, 2); // true\najv.validate(schema, 3); // true\najv.validate(schema, 0.99); // false\najv.validate(schema, 3.01); // false\n\nvar schema = { range: [1, 3], exclusiveRange: true };\najv.validate(schema, 1.01); // true\najv.validate(schema, 2); // true\najv.validate(schema, 2.99); // true\najv.validate(schema, 1); // false\najv.validate(schema, 3); // false\n```\n\n\n### `propertyNames`\n\nThis keyword allows to define the schema for the property names of the object. The value of this keyword should be a valid JSON schema (v5 schemas are supported with Ajv option `{v5: true}`).\n\n```javascript\nvar schema = {\n  type: 'object'\n  propertyNames: {\n    anyOf: [\n      { format: ipv4 },\n      { format: hostname }\n    ]\n  }\n};\n\nvar validData = {\n  '192.128.0.1': {},\n  'test.example.com': {}\n};\n\nvar invalidData = {\n  '1.2.3': {}\n};\n\najv.validate(schema, validData); // true\najv.validate(schema, invalidData); // false\n```\n\n__Please note__: This keyword will be added to the next version of the JSON-Schema standard (draft-6), after it is published the keyword will be included in Ajv as standard validation keyword.\n\n\n### `if`/`then`/`else`\n\nThese keywords allow to implement conditional validation. Their values should be valid JSON-schemas. At the moment it requires using Ajv with v5 option.\n\nIf the data is valid according to the sub-schema in `if` keyword, then the result is equal to the result of data validation against the sub-schema in `then` keyword, otherwise - in `else` keyword (if `else` is absent, the validation succeeds).\n\n```javascript\nrequire('ajv-keywords')(ajv, 'if');\n\nvar schema = {\n  type: 'array',\n  items: {\n    type: 'integer',\n    minimum: 1,\n    if: { maximum: 10 },\n    then: { multipleOf: 2 },\n    else: { multipleOf: 5 }\n  }\n};\n\nvar validItems = [ 2, 4, 6, 8, 10, 15, 20, 25 ]; // etc.\n\nvar invalidItems = [ 1, 3, 5, 11, 12 ]; // etc.\n\najv.validate(schema, validItems); // true\najv.validate(schema, invalidItems); // false\n```\n\nThis keyword is [proposed](https://github.com/json-schema-org/json-schema-spec/issues/180) for the future version of JSON-Schema standard.\n\n\n### `prohibited`\n\nThis keyword allows to prohibit that any of the properties in the list is present in the object.\n\nThis keyword applies only to objects. If the data is not an object, the validation succeeds.\n\nThe value of this keyword should be an array of strings, each string being a property name. For data object to be valid none of the properties in this array should be present in the object.\n\n```\nvar schema = { prohibited: ['foo', 'bar']};\n\nvar validData = { baz: 1 };\nvar alsoValidData = {};\n\nvar invalidDataList = [\n  { foo: 1 },\n  { bar: 2 },\n  { foo: 1, bar: 2}\n];\n```\n\n\n### `deepRequired`\n\nThis keyword allows to check that some deep properties (identified by JSON pointers) are available. The value should be an array of JSON pointers to the data, starting from the current position in data.\n\n```javascript\nvar schema = {\n  type: 'object',\n  deepRequired: [\"/users/1/role\"]\n};\n\nvar validData = {\n  users: [\n    {},\n    {\n      id: 123,\n      role: 'admin'\n    }\n  ]\n};\n\nvar invalidData = {\n  users: [\n    {},\n    {\n      id: 123\n    }\n  ]\n};\n```\n\nSee [json-schema-org/json-schema-spec#203](https://github.com/json-schema-org/json-schema-spec/issues/203#issue-197211916) for an example of the equivalent schema without `deepRequired` keyword.\n\n\n## `deepProperties`\n\nThis keyword allows to validate deep properties (identified by JSON pointers). The value should be an object, where keys are JSON pointers to the data, starting from the current position in data, and the values are corresponding schemas.\n\n```javascript\nvar schema = {\n  type: 'object',\n  deepProperties: {\n    \"/users/1/role\": { \"enum\": [\"admin\"] }\n  }\n};\n\nvar validData = {\n  users: [\n    {},\n    {\n      id: 123,\n      role: 'admin'\n    }\n  ]\n};\n\nvar alsoValidData = {\n  users: {\n    \"1\": {\n      id: 123,\n      role: 'admin'\n    }\n  }\n};\n\nvar invalidData = {\n  users: [\n    {},\n    {\n      id: 123,\n      role: 'user'\n    }\n  ]\n};\n\nvar alsoInvalidData = {\n  users: {\n    \"1\": {\n      id: 123,\n      role: 'user'\n    }\n  }\n};\n```\n\n\n### `regexp`\n\nThis keyword allows to use regular expressions with flags in schemas (the standard `pattern` keyword does not support flags). The value of this keyword can be either a string (the result of `regexp.toString()`) or an object with the properties `pattern` and `flags` (the same strings that should be passed to RegExp constructor).\n\n```javascript\nvar schema = {\n  type: 'object',\n  properties: {\n    foo: { regexp: '/foo/i' },\n    bar: { regexp: { pattern: 'bar', flags: 'i' } }\n  }\n};\n\nvar validData = {\n  foo: 'Food',\n  bar: 'Barmen'\n};\n\nvar invalidData = {\n  foo: 'fog',\n  bar: 'bad'\n};\n```\n\n\n### `dynamicDefaults`\n\nThis keyword allows to assign dynamic defaults to properties, such as timestamps, unique IDs etc.\n\nThis keyword only works if `useDefaults` options is used and not inside `anyOf` keywrods etc., in the same way as [default keyword treated by Ajv](https://github.com/epoberezkin/ajv#assigning-defaults).\n\nThe keyword should be added on the object level. Its value should be an object with each property corresponding to a property name, in the same way as in standard `properties` keyword. The value of each property can be:\n\n- an identifier of default function (a string)\n- an object with properties `func` (an identifier) and `args` (an object with parameters that will be passed to this function during schema compilation - see examples).\n\nThe properties used in `dynamicDefaults` should not be added to `required` keyword (or validation will fail), because unlike `default` this keyword is processed after validation.\n\nThere are several predefined dynamic default functions:\n\n- `\"timestamp\"` - current timestamp in milliseconds\n- `\"datetime\"` - current date and time as string (ISO, valid according to `date-time` format)\n- `\"date\"` - current date as string (ISO, valid according to `date` format)\n- `\"time\"` - current time as string (ISO, valid according to `time` format)\n- `\"random\"` - pseudo-random number in [0, 1) interval\n- `\"randomint\"` - pseudo-random integer number. If string is used as a property value, the function will randomly return 0 or 1. If object `{func: 'randomint', max: N}` is used then the default will be an integer number in [0, N) interval.\n- `\"seq\"` - sequential integer number starting from 0. If string is used as a property value, the default sequence will be used. If object `{func: 'seq', name: 'foo'}` is used then the sequence with name `\"foo\"` will be used. Sequences are global, even if different ajv instances are used.\n\n```javascript\nvar schema = {\n  type: 'object',\n  dynamicDefaults: {\n    ts: 'datetime',\n    r: { func: 'randomint', max: 100 },\n    id: { func: 'seq', name: 'id' }\n  },\n  properties: {\n    ts: {\n      type: 'string',\n      format: 'datetime'\n    },\n    r: {\n      type: 'integer',\n      minimum: 0,\n      maximum: 100,\n      exclusiveMaximum: true\n    },\n    id: {\n      type: 'integer',\n      minimum: 0\n    }\n  }\n};\n\nvar data = {};\najv.validate(data); // true\ndata; // { ts: '2016-12-01T22:07:28.829Z', r: 25, id: 0 }\n\nvar data1 = {};\najv.validate(data1); // true\ndata1; // { ts: '2016-12-01T22:07:29.832Z', r: 68, id: 1 }\n\najv.validate(data1); // true\ndata1; // didn't change, as all properties were defined\n```\n\nYou can add your own dynamic default function to be recognised by this keyword:\n\n```javascript\nvar uuid = require('uuid');\n\nfunction uuidV4() { return uuid.v4(); }\n\nvar definition = require('ajv-keywords').get('dynamicDefaults').definition;\n// or require('ajv-keywords/keywords/dynamicDefaults').definition;\ndefinition.DEFAULTS.uuid = uuidV4;\n\nvar schema = {\n  dynamicDefaults: { id: 'uuid' },\n  properties: { id: { type: 'string', format: 'uuid' } }\n};\n\nvar data = {};\najv.validate(schema, data); // true\ndata; // { id: 'a1183fbe-697b-4030-9bcc-cfeb282a9150' };\n\nvar data1 = {};\najv.validate(schema, data1); // true\ndata1; // { id: '5b008de7-1669-467a-a5c6-70fa244d7209' }\n```\n\nYou also can define dynamic default that accepts parameters, e.g. version of uuid:\n\n```javascript\nvar uuid = require('uuid');\n\nfunction getUuid(args) {\n  var version = 'v' + (arvs && args.v || 4);\n  return function() {\n    return uuid[version]();\n  };\n}\n\nvar definition = require('ajv-keywords').get('dynamicDefaults').definition;\ndefinition.DEFAULTS.uuid = getUuid;\n\nvar schema = {\n  dynamicDefaults: {\n    id1: 'uuid', // v4\n    id2: { func: 'uuid', v: 4 }, // v4\n    id3: { func: 'uuid', v: 1 } // v1\n  }\n};\n```\n\n\n## License\n\n[MIT](https://github.com/JSONScript/ajv-keywords/blob/master/LICENSE)\n",
  "readmeFilename": "README.md",
  "_id": "ajv-keywords@1.5.1",
  "dist": {
    "shasum": "507f51d441c81afc481a528cd533ea75687700e4"
  },
  "_from": "ajv-keywords@^1.1.1",
  "_resolved": "http://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz"
}