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

Migration error with negative lookahead in regexp validation #1285

Open
dt-rtlayzell opened this issue Jan 17, 2024 · 1 comment
Open

Migration error with negative lookahead in regexp validation #1285

dt-rtlayzell opened this issue Jan 17, 2024 · 1 comment

Comments

@dt-rtlayzell
Copy link

dt-rtlayzell commented Jan 17, 2024

version: 4.19.1

Adding a validation with a regexp that contains a negative lookahead appears to cause an error during migration, but adding the same pattern directly in Contentful UI works perfectly fine.

{
  "status": "Unprocessable Entity",
  "message": "Validation error",
  "details": {
    "errors": [
      {
        "name": "invalid",
        "details": "The property \"regexp\" is not valid",
        "path": [
          "fields",
          10,
          "validations",
          0,
          "regexp"
        ],
        "value": {
          "pattern": "^(?!hello\\s)world$",
          "flags": "i"
        }
      }
    ]
  }
}
@monkishtypist
Copy link

I know this is old but...

I have found that Contentful does not like negative lookahead, so instead I use negated sets:

^[^hello\s]*(world)$

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

No branches or pull requests

2 participants