/athena

Rules language for JSON files

Primary LanguageTypeScriptMIT LicenseMIT

Athena

Athena is a validation language for JSON files. With this validator, you can ensure your JSON files meet specific criteria, making data validation straightforward and reliable. All you need to do is to create a schema that describes the rules for validating JSON file, and you'll get the result!

Design document

Link to the design document

Getting started

  1. Create a schema: Create a schema file using Athena's syntax that describes all the rules for validating your JSON data.
  2. Run Athena: Run the validator program passing your schema and the JSON file you're validating as parameters.
  3. Review results: The program will inform you on whether your JSON file is valid or not based on the provided schema.

Installation

  1. Ensure you have Node.js >=18.18.0 installed.
  2. Clone this repository:
git clone https://github.com/Olympus-Group/athena.git
  1. Install dependencies:
npm install

Running the program

Run the program with this command

npx ts-node index.ts ['-s, --schema <file.schema>'] ['-c, --config <file.json>'] | ['-h --help']

['-s, --schema <file.schema>']required option: filepath to schema

['-c, --config <file.json>']required option: filepath to JSON config

['-h --help']optional parameter: information about all options supported by CLI

Running tests

In general mode:

npm test

In developer mode:

npm run test:dev

Examples

Rules supported by Athena's schemas:

Rule Rule's value type Description
required bool States whether the field is required
optional bool States whether the field is optional
isNotEmpty bool Checks whether the field is not empty
equals any Checks whether the field's value is equal to rule's value
notEquals any Checks whether the field's value is not equal to rule's value
isString bool Checks whether the field's value is a string
notString bool Checks whether the field's value is not a string
isNumber bool Checks whether the field's value is a number
notNumber bool Checks whether the field's value is not a number
isBool bool Checks whether the field's value is boolean
notBool bool Checks whether the field's value is not boolean
isUUID bool Checks whether the field's value is a UUID
isDatetime bool Checks whether the field's value is a Datetime value
isNegative bool Checks whether the field's value is negative
isPositive bool Checks whether the field's value is positive
min number Checks whether the field's value is more than minimal value
max number Checks whether the field's value is less than maximal value

Examples of full schemas and JSON configs can be found in .\test\static

Coming soon

  • support of arrays as a type of data in fields
  • support of nested JSON files validation