contentful / contentful-migration

🚚 Migration tooling for contentful
MIT License
328 stars 150 forks source link

Migration error with negative lookahead in regexp validation #1285

Open dt-rtlayzell opened 10 months ago

dt-rtlayzell commented 10 months ago

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 commented 4 months ago

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)$