ang-token-validator

1.2.1 • Public • Published

ANG Token Validator

v2 usage:

/* import validator **/
import angTokenValidator from 'ang-token-validator';

/* set expressions to validate **/ 
expressionsParameters = {
    name: "yourIdentifier",
    schema: "theSchemaObjectToValidate",
    jsonPathExpression: "the path to expression"
};
/* or **/
expressionsParameters = [{
    name: "yourIdentifier",
    schema: "theSchemaObjectToValidate",
    jsonPathExpression: "the path to expression"
    },
    {
        ...
    }];

the three parameters in expressionsParameters are mandatory.

expressionParameters can be either an object or an array of object with schema's and path's to validate.

then you can call the function

    const response = angTokenValidator.validate(token, expressionsParameters, key);

case 1 one response with no errors:

{
  "IdentifierName": {
    "result": {
      "key1": "val1",
      "key2": "val2"
    },
  }
}

case 1 one response with errors:

{
  "IdentifierName": {
    "error": {
      "message": "the error message",
      "statusCode": 400, 401, 403, 503, ...
    },
  }
}

case 2 multiple response:

[
  { "IdentifierName": { error: [Object] } },
  { "IdentifierName": { error: [Object] } },
  { "IdentifierName": { error: [Object] } }

]

[
  { "IdentifierName": { result: [Object] } },
  { "IdentifierName": { result: [Object] } },
  { "IdentifierName": { result: [Object] } }
]

v1 usage:

import angTokenValidator from 'ang-token-validator';


const result = angTokenValidator.validate(schema, token, jsonPathQuery)
- schema is the schema to validate
- token is as is name the token
- jsonPathQuery is the path to the schema to validate in the token

Readme

Keywords

Package Sidebar

Install

npm i ang-token-validator

Weekly Downloads

0

Version

1.2.1

License

ISC

Unpacked Size

5.82 kB

Total Files

7

Last publish

Collaborators

  • dsebban