Skip to content

Should the regex for deepProperties be improved? #384

@jeremycare

Description

@jeremycare

Hi,

I open this issue because deepProperties doesn't work with keys that have numbers in them.

const schema = {
  type: 'object',
  deepProperties: {
    '/audio.2.0/requireForced': {
      const: true,
    },
  },
};

this produces the following error:

Error: schema is invalid: data/allOf/0/items must be object,boolean, data/allOf/0/items must be object,boolean, data/allOf/0/items must be object,boolean, data/allOf/0/items must be object,boolean, data/allOf/0/items must be object,boolean, data/allOf/0/items must be object,boolean, data/allOf/0/items must be object,boolean, data/allOf/0/items must be object,boolean

After my research, I've seen that this is due to this line in the deepProperties getSchema function.

if (/[0-9]+/.test(segment)) {

This raises multiples questions to me:

  1. is it compliant with the JSON Schema standard to have numbers part of string fields? (I wasn't able to properly find a answer for that)
  2. Is this project maintained? (I've seen that the last commit was 2 years ago.)
    2.1 if yes -> Is a PR welcome to update that?
    2.2 if no -> If it's not maintained anymore I can probably fork it and modify it for ourselves. And not bother you more (sorry for the Issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions