New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

asl-validator

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asl-validator - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

src/__tests__/definitions/invalid-json-path.json

5

package.json
{
"name": "asl-validator",
"version": "1.0.5",
"version": "1.0.6",
"description": "Amazon States Language validator",

@@ -34,3 +34,4 @@ "main": "./src/validator.js",

"ajv": "^5.3.0",
"commander": "^2.11.0"
"commander": "^2.11.0",
"jsonpath": "^1.0.0"
},

@@ -37,0 +38,0 @@ "devDependencies": {

2

README.md

@@ -9,3 +9,3 @@ # asl-validator

A simple [**Amazon States Language**](https://states-language.net/spec.html) validator based on JSON schemas.
A simple [**Amazon States Language**](https://states-language.net/spec.html) validator based on JSON schemas. It also validates JSON paths syntax in `InputPath`, `OutputPath` and `ResultPath`.

@@ -12,0 +12,0 @@ When writing your state machine (for AWS step functions), you can't locally validate you state machine definition without creating it. `asl-validator` makes it possible.

@@ -17,5 +17,7 @@ const fs = require('fs');

expect(isValid).toBeTruthy();
expect(errors).toBeNull();
expect(Array.isArray(errors)).toBeTruthy();
expect(errors.length).toEqual(0);
} else if (match[1] === 'invalid') {
expect(isValid).toBeFalsy();
expect(Array.isArray(errors)).toBeTruthy();
expect(errors.length).toBeGreaterThan(0);

@@ -22,0 +24,0 @@ }

const Ajv = require('ajv');
const jp = require('jsonpath');

@@ -27,6 +28,24 @@ const choice = require('./schemas/choice');

});
const isValid = ajv.validate('http://asl-validator.cloud/state-machine#', definition);
return { isValid, errors: ajv.errors };
// Validating JSON paths
const jsonPathErrors = jp.query(definition, '$..[\'InputPath\',\'OutputPath\',\'ResultPath\']')
.map((path) => {
try {
jp.parse(path);
return null;
} catch (e) {
return e;
}
})
.filter(parsed => parsed); // remove null values to keep only errors
// Validating JSON schemas
const isJsonSchemaValid = ajv.validate('http://asl-validator.cloud/state-machine#', definition);
return {
isValid: isJsonSchemaValid && !jsonPathErrors.length,
errors: jsonPathErrors.concat(ajv.errors || []),
};
}
module.exports = validator;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc