membrane-php / membrane-core

Membrane is a general purpose input validation library, supports both PHP Attributes and OpenAPI specifications
Other
1 stars 2 forks source link

length validation for special characters not working as expected #171

Closed Kaplonx closed 6 months ago

Kaplonx commented 8 months ago

The maxLength property validation does not work as expected when using special characters like ä.

Example:

Address:
  title: Address
  type: object
  properties:
    street_name:
      type: string
      minLength: 1
      maxLength: 6
      pattern: '^([a-zA-Z0-9]||[äöü])*$'
      example: street

Input street_name = aaaaaa works fine Input street_name = ääää fails with an error for the length.

Expected behaviour would be that ääääää is an allowed input.

This might be related to the utf-8 encoding of those special characters being a combination of two base characters: https://www.compart.com/en/unicode/U+00E4