Skip to content

the regexp keyword cashes pattern without taking flags into account #220

Closed
@changk99

Description

@changk99

ajv: '^8.6.3'
ajv-keywords: '^5.0.0'

const Ajv = require('ajv').default
const ajv = new Ajv()
const ajvKeywords = require('ajv-keywords')
ajvKeywords(ajv)
const stringSchema = {
  type: 'string',
  pattern: 'a'
}
const stringSchema3 = {
  $id: 'regexp',
  type: 'string',
  regexp: {
    pattern: 'a',
    flags: 'i'
  }
}
console.log(ajv.validate(stringSchema, "a")) // true
console.log(ajv.validate(stringSchema3, "A")) // false

I expect the second logger to output true

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions