0.1.1 • Published 2 years ago

@janiscommerce/batch-schema-validator v0.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

batch-schema-validator

Build Status Coverage Status npm version

Validator for Batch Schemas for JANIS BATCH SERVICE

:package: Usage (command line)

npx @janiscommerce/batch-schema-validator

:gear: Configuration

  • Schemas MUST be located at:
batch-schemas
|__import
|____entity.yml
|__export
|____entity.yml
|
src

:warning: Important

  • Any other location will be ignored

  • The batch schemas files must be .yml or .yaml. Any other file types will be skipped after showing warning.

  • If there is not any source files in the specified input directory no error will be thrown

Import Schema Struct

Each Import Schema will be validated according the following struct

fields: string
 - name: string
   label: string 
   field: string 
   isArray: boolean
   separator: string
   format: array
    name: string
    props: object
   nullable: boolean 

Fields (REQUIRED)

  • name: REQUIRED.
  • label: OPTIONAL.
  • field: OPTIONAL.
  • isArray: OPTIONAL.
  • separator:OPTIONAL. Default value ---> ,
  • format OPTIONAL.
  • nullable OPTIONAL.

Check here for more info about import schemas.

Export Schema Struct

Each Import Schema will be validated according the following struct

dependencies:
  - name: string
    source:
      service: string
      namespace: string
      method: string
    filters:
      id: string

fields:
  - name: string
    label: string
    dependsOn: string
    field: string

Dependencies (OPTIONAL)

  • name: REQUIRED.
  • source: REQUIRED.
    • service: REQUIRED.
    • namespace: REQUIRED.
    • method: REQUIRED. Valid values ---> list
  • filters: REQUIRED.

Fields (REQUIRED)

  • name: REQUIRED.
  • label: OPTIONAL.
  • field: OPTIONAL.
  • separator:OPTIONAL. Default value ---> ,
  • format OPTIONAL.
    • name: REQUIRED.
    • props: REQUIRED.

Check here for more info about export schemas.

Error types

It also uses the following error codes:

NameValueDescription
Read files1Something went wrong while reading source files. Not related with schemas errors
Schema validation2Invalid schemas were found
Parsing schema3Something went wrong while parsing source files from yml/yaml to json

Validated Errors

  • Struct Errors
  • Value Type Errors
  • Required fields

Validated Warnings

  • Extra properties in schemas
  • Default values
  • Redundant properties definitions