Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format: uri failing validation with draft-04 schemas #81

Open
jeremyfiel opened this issue Feb 28, 2023 · 0 comments
Open

format: uri failing validation with draft-04 schemas #81

jeremyfiel opened this issue Feb 28, 2023 · 0 comments

Comments

@jeremyfiel
Copy link

jeremyfiel commented Feb 28, 2023

Hello

I'm trying to validate a draft-04 schema with format: uri but my example data is failing for format should match uri

  "dependencies": {
    "ajv": "^8.11.0",
    "ajv-draft-04": "^1.0.0",
    "ajv-formats":"^2.1.1",
const Ajv = require("ajv-draft-04");
const addFormats = require('ajv-formats')

let _ajvOptions = {
  strict: false,
  verbose: true,
  allErrors: true
};

let results;
let data = {...}
let schema = {...}

try {
    let ajv = new Ajv(_ajvOptions);
    addFormats(ajv)

    let _draft4Validator = ajv.compile(schema);
  }

  let valid = _draft4Validator(data);

  console.log(
    (results = {
      valid: valid,
      error: _draft4Validator.errors,
    })
  );
} catch (err) {
  console.error(
    (results = {
      valid: false,
      error: err,
    })
  );
}

It was brought to my attention the ajv-formats package doesn't have a way to interpret which draft should be followed and thus the behavior changes of uri between draft-04 and draft-06+ are not accounted for.

Is there a good work around to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant