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

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

Closed
changk99 opened this issue Sep 26, 2021 · 1 comment
Closed
Labels

Comments

@changk99
Copy link

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

@epoberezkin epoberezkin changed the title the regexp keyword Unexpected behavior the regexp keyword cashes pattern without taking flags into account Nov 21, 2021
@epoberezkin
Copy link
Member

this is specifically caused by the presence of the first schema, the regexp keyword looks up patterns in the same dictionary, by pattern, without taking flags into account... So this would do the same:

const Ajv = require('ajv').default
const ajv = new Ajv()
const ajvKeywords = require('ajv-keywords')
ajvKeywords(ajv)
const stringSchema1 = {
  type: 'string',
  regexp: {
    pattern: 'a'
  }
}
const stringSchema2 = {
  $id: 'regexp',
  type: 'string',
  regexp: {
    pattern: 'a',
    flags: 'i'
  }
}
console.log(ajv.validate(stringSchema1, "a")) // true
console.log(ajv.validate(stringSchema1, "A")) // false
console.log(ajv.validate(stringSchema2, "A")) // false, even though it should be true (and it is true in case there is no first schema)

hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this issue Mar 12, 2024
## [0.5.8](https://github.com/equinor/webviz-subsurface-components/compare/wsc-common@0.5.7...wsc-common@0.5.8) (2024-03-12)

### Bug Fixes

* bump ajv from 7.2.1 to 8.12.0 in /typescript ([#1947](#1947)) ([af95651](af95651)), closes [#2190](https://github.com/equinor/webviz-subsurface-components/issues/2190) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [ajv-validator/ajv#1840](ajv-validator/ajv#1840) [#1840](#1840) [#1901](#1901) [#1922](#1922) [#1862](#1862) [#1861](#1861) [#1815](#1815) [ajv-validator/ajv-keywords#220](ajv-validator/ajv-keywords#220) [#1819](#1819) [#1725](#1725) [#1757](#1757) [#2195](https://github.com/equinor/webviz-subsurface-components/issues/2195) [#1971](#1971) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2184](https://github.com/equinor/webviz-subsurface-components/issues/2184) [#2193](https://github.com/equinor/webviz-subsurface-components/issues/2193) [#2183](https://github.com/equinor/webviz-subsurface-components/issues/2183) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2160](https://github.com/equinor/webviz-subsurface-components/issues/2160) [#1935](#1935) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [#1949](#1949) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191)
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this issue Mar 12, 2024
## [1.2.8](https://github.com/equinor/webviz-subsurface-components/compare/well-completions-plot@1.2.7...well-completions-plot@1.2.8) (2024-03-12)

### Bug Fixes

* bump ajv from 7.2.1 to 8.12.0 in /typescript ([#1947](#1947)) ([af95651](af95651)), closes [#2190](https://github.com/equinor/webviz-subsurface-components/issues/2190) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [ajv-validator/ajv#1840](ajv-validator/ajv#1840) [#1840](#1840) [#1901](#1901) [#1922](#1922) [#1862](#1862) [#1861](#1861) [#1815](#1815) [ajv-validator/ajv-keywords#220](ajv-validator/ajv-keywords#220) [#1819](#1819) [#1725](#1725) [#1757](#1757) [#2195](https://github.com/equinor/webviz-subsurface-components/issues/2195) [#1971](#1971) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2184](https://github.com/equinor/webviz-subsurface-components/issues/2184) [#2193](https://github.com/equinor/webviz-subsurface-components/issues/2193) [#2183](https://github.com/equinor/webviz-subsurface-components/issues/2183) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2160](https://github.com/equinor/webviz-subsurface-components/issues/2160) [#1935](#1935) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [#1949](#1949) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191)
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this issue Mar 12, 2024
## [0.20.1](https://github.com/equinor/webviz-subsurface-components/compare/subsurface-viewer@0.20.0...subsurface-viewer@0.20.1) (2024-03-12)

### Bug Fixes

* bump ajv from 7.2.1 to 8.12.0 in /typescript ([#1947](#1947)) ([af95651](af95651)), closes [#2190](https://github.com/equinor/webviz-subsurface-components/issues/2190) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [ajv-validator/ajv#1840](ajv-validator/ajv#1840) [#1840](#1840) [#1901](#1901) [#1922](#1922) [#1862](#1862) [#1861](#1861) [#1815](#1815) [ajv-validator/ajv-keywords#220](ajv-validator/ajv-keywords#220) [#1819](#1819) [#1725](#1725) [#1757](#1757) [#2195](https://github.com/equinor/webviz-subsurface-components/issues/2195) [#1971](#1971) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2184](https://github.com/equinor/webviz-subsurface-components/issues/2184) [#2193](https://github.com/equinor/webviz-subsurface-components/issues/2193) [#2183](https://github.com/equinor/webviz-subsurface-components/issues/2183) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2160](https://github.com/equinor/webviz-subsurface-components/issues/2160) [#1935](#1935) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [#1949](#1949) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191)
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this issue Mar 12, 2024
## [1.1.8](https://github.com/equinor/webviz-subsurface-components/compare/group-tree-plot@1.1.7...group-tree-plot@1.1.8) (2024-03-12)

### Bug Fixes

* bump ajv from 7.2.1 to 8.12.0 in /typescript ([#1947](#1947)) ([af95651](af95651)), closes [#2190](https://github.com/equinor/webviz-subsurface-components/issues/2190) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [ajv-validator/ajv#1840](ajv-validator/ajv#1840) [#1840](#1840) [#1901](#1901) [#1922](#1922) [#1862](#1862) [#1861](#1861) [#1815](#1815) [ajv-validator/ajv-keywords#220](ajv-validator/ajv-keywords#220) [#1819](#1819) [#1725](#1725) [#1757](#1757) [#2195](https://github.com/equinor/webviz-subsurface-components/issues/2195) [#1971](#1971) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2184](https://github.com/equinor/webviz-subsurface-components/issues/2184) [#2193](https://github.com/equinor/webviz-subsurface-components/issues/2193) [#2183](https://github.com/equinor/webviz-subsurface-components/issues/2183) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2160](https://github.com/equinor/webviz-subsurface-components/issues/2160) [#1935](#1935) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [#1949](#1949) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191)
hkfb pushed a commit to equinor/webviz-subsurface-components that referenced this issue Mar 12, 2024
## [1.5.1](https://github.com/equinor/webviz-subsurface-components/compare/well-log-viewer@1.5.0...well-log-viewer@1.5.1) (2024-03-12)

### Bug Fixes

* bump ajv from 7.2.1 to 8.12.0 in /typescript ([#1947](#1947)) ([af95651](af95651)), closes [#2190](https://github.com/equinor/webviz-subsurface-components/issues/2190) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [ajv-validator/ajv#1840](ajv-validator/ajv#1840) [#1840](#1840) [#1901](#1901) [#1922](#1922) [#1862](#1862) [#1861](#1861) [#1815](#1815) [ajv-validator/ajv-keywords#220](ajv-validator/ajv-keywords#220) [#1819](#1819) [#1725](#1725) [#1757](#1757) [#2195](https://github.com/equinor/webviz-subsurface-components/issues/2195) [#1971](#1971) [#2194](https://github.com/equinor/webviz-subsurface-components/issues/2194) [#2184](https://github.com/equinor/webviz-subsurface-components/issues/2184) [#2193](https://github.com/equinor/webviz-subsurface-components/issues/2193) [#2183](https://github.com/equinor/webviz-subsurface-components/issues/2183) [#2158](https://github.com/equinor/webviz-subsurface-components/issues/2158) [#2160](https://github.com/equinor/webviz-subsurface-components/issues/2160) [#1935](#1935) [#2192](https://github.com/equinor/webviz-subsurface-components/issues/2192) [#1949](#1949) [#2191](https://github.com/equinor/webviz-subsurface-components/issues/2191)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants