Code Monkey home page Code Monkey logo

schema-validator's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

schema-validator's Issues

Logging should be optional

I have a request, can we have the logging as optional or add an optional level lets say, verbose, warn and error.

It would help reduce the amount of logs on the terminal.

Unable to run `schema` on MacOS due to wrong line endings

The schema bin file uses windows style line endings (\r\n) and this breaks attempts to use the package on non-windows systems.
The edge case here is that npm performs conversion of \r\n to \n for "bins" files, but yarn does not.

Wildcard parent

Hi great module. Thanks for this one.

I have a need to check child key/values under parents with wildcards.

Example:

foo:
  bar:
    color: blue
  baz:
    color: red

Where color needs to be checked but it's immediate parent is not always known: foo.*.color. Anyway to accomplish this?

Validate Regex?

Hi,

I want to validate whether the given yaml parameter matches a certain regex. Is this possible somehow?

Example:

IP:
  type: string
  required: true
  regex: ^\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b$

CLI: return a nonzero status when validation fails

This tool is great, but so far int merely prints errors and warnings, which makes it difficult to evaluate the validation status e.g. by a CI script or pre-commit hook.

A naïve implementation might just evaluate the list of errors and warnings and exit the process with a non-zero status:

    const errorsAndWarnings = validateSchema(targetObj, options)
    if (errorsAndWarnings?.length > 0) {
      process.exit(1)
    }

mocha --opts not working anymore

As soon as I include "yaml-schema-validator": "^1.1.9" in my package.json and npm install it, mocha --opts mocha.opts fails with this error message:

$ mocha --opts mocha.opts
error: unknown option `--opts'

My project has these dependencies:

"devDependencies": {
    "chai": "^4.2.0",
    "chai-as-promised": "^7.1.1",
    "eslint": "^6.5.1",
    "eslint-config-airbnb-base": "^14.0.0",
    "eslint-plugin-import": "^2.14.0",
    "fast-xml-parser": "3.13.0",
    "mocha": "^6.2.1",
    "nyc": "^14.1.1",
    "yaml-schema-validator": "^1.1.9"
  },
  "dependencies": {
    "app-root-path": "^2.2.1",
    "bluebird": "^3.7.0",
    "config": "^3.2.3",
    "glob": "^7.1.4",
    "js-yaml": "^3.13.1",
    "json5": "^2.1.1",
    "jszip": "^3.2.2",
    "lodash": "^4.17.11",
    "moment": "^2.22.2",
    "moment-range": "^4.0.1",
    "moment-timezone": "^0.5.23",
    "normalize-path": "^3.0.0",
    "ramda": "^0.26.1",
    "sql.js": "^1.0.0",
    "winston": "^3.2.1",
    "yargs": "^14.2.0"
  }

If I remove yaml-schema-validator, the command mocha --opts mocha.opts runs all tests as expected.

The problematic behavior is observed regardless of platform, it's the same on Linux, Windows, or macOS. Node.js version 10.16.3 was used.

how to validate array of elements?

services:
- name: a name
  ports:
    - port: 81
      service: web
    - port: 10101
      service: api

- name: another name
  ports:
    - port: 2801
      name: api
    - port: 2802
      name: mysql
    - port: 31975
      service: nodePort/public api
    - port: 31976
      service: nodePort/internal api

`Schema` - ReferenceError: Schema is not defined

Thank you for writing this, I find your library to be super helpful!

ISSUE
Upon execution of your example, I get the following error:

ReferenceError: Schema is not defined

I was not able to locate your definition/import of Schema in your code.

CODE

// custom validation function checking value for a regex
const checkHexColor = val => {
  return /^#[0-9a-fA-F]$/.test(val)
}

const car = new Schema({
  color: {
    type: String,
    use: { checkHexColor }
  }
})

multi level yml check

Required not working correctly on multi level file. For example
I define schema as:

person: 
   name:
      type: string
      required: true
   dob:
      type: string
car:
   name:
      type: string
      required: true

and my yml under test can be:

car:
    name: 'BMW'

So it should not complain person.name is required.
Currently it complain that person.name is missing. It should only complain if upper level object exist eg

car:
    name: 'BMW'
person:
   dob: 24-10

Using with yargs, it overrides options

Compatibility issue with yargs package. When i try to use both while creating my owm cmd tool, options for schema-validator overrides my yargs options

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.