ketanSaxena / schema-validator

Schema validation utility for YAML/JSON files against a pre defined schema
https://ketantechracers.github.io/schema-validator
MIT License
36 stars 17 forks source link

`Schema` - ReferenceError: Schema is not defined #20

Open bigoper opened 3 years ago

bigoper commented 3 years ago

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 }
  }
})
PseudoCoding commented 3 years ago

ditto this

MattiSG commented 1 year ago

This seems to be a pure documentation issue. Just passing a base JS object instead of trying to instantiate a Schema instance works with validateSchema 🙂