Skip to content

Add regex pattern validation support for custom fields #18655

@juancamilo49

Description

@juancamilo49

Scope & Context

We are working with custom fields on People and Companies objects in Twenty CRM. This ticket is about adding regex pattern validation support when creating or editing custom fields in a workspace.

Currently, Twenty CRM allows users to create custom text fields for objects (e.g., a "License Plate" field on People), but there is no way to enforce a specific format or pattern on the input. This is already supported in other platforms like Chatwoot's custom attributes, which allow defining a regex pattern and a hint message.

Current behavior

When creating a custom field for an object (e.g., People or Companies), the user can set a name, type, and description — but there is no option to define a validation pattern or regex for the field value.

This means that a field like "License Plate" (expected format: 3 uppercase letters + 3 digits, e.g. ABC123) accepts any arbitrary string with no validation, leading to inconsistent data quality across contacts.

Image

Expected behavior

When creating or editing a custom field of type Text, the user should be able to optionally define:

  • A Regex pattern — a regular expression the field value must match (e.g. ^[A-Z]{3}[0-9]{3}$)
  • A Pattern hint — a short message shown to the user explaining the expected format (e.g. Format: 3 uppercase letters followed by 3 digits. Example: ABC123)

If a value is entered that does not match the defined pattern, the field should display an inline validation error and prevent saving until corrected.

The following screenshot shows how Chatwoot implements this same feature
in their custom attributes — this is the expected UX behavior:

Image

Technical inputs

  • Add optional validationPattern (string) and validationHint (string) properties to the custom field schema
  • On the field creation/edit form, add a collapsible "Validation" section with inputs for regex pattern and hint
  • On the field input component, apply RegExp(validationPattern).test(value) before allowing save
  • Display validationHint as helper text below the field input when a pattern is defined
  • Store both properties in the field metadata alongside existing properties like label and description

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions