feat: add regex validation to custom text fields - #1
Open
intivalderas wants to merge 5 commits into
Open
Conversation
intivalderas
force-pushed
the
feat/text-field-regex-validation
branch
from
March 30, 2026 20:44
82e0734 to
4212c83
Compare
Created by Github action Co-authored-by: github-actions <github-actions@twenty.com>
Allows workspace admins to configure a regex pattern on any custom text field. Values are validated both client-side (red border + snackbar on save) and server-side (throws on record create/update). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
intivalderas
force-pushed
the
feat/text-field-regex-validation
branch
from
March 30, 2026 22:36
2d198be to
36fc409
Compare
- update universal-flat-field-metadata type-test for the new TEXT settings fields (validationPattern, validationErrorMessage) — fixes server typecheck - name the field-in-error setter after its state to satisfy the matching-state-variable lint rule (fixes front lint) - replace `(errors as any)` with typed react-hook-form error access - translate default validation messages via t/msg instead of hardcoded English strings - guard with isNonEmptyString and de-duplicate the regex check in TextFieldInput - add unit tests for validateTextFieldOrThrow (pattern cases) and validateTextFlatFieldMetadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
twenty-sharedFieldMetadataSettings.ts— addedvalidationPatternandvalidationErrorMessagetoFieldMetadataTextSettingstwenty-servervalidate-text-flat-field-metadata.util.ts(new) — validates the regex is syntactically valid on field saveflat-field-metadata-type-validator.service.ts— wiredTEXTto the new validatorvalidate-text-field-or-throw.util.ts— enforces the pattern on record value savedata-arg-processor.service.ts— passessettingsto the text validatortwenty-frontFieldMetadata.ts— extendedFieldTextMetadatawithvalidationPatternandvalidationErrorMessageSettingsDataModelFieldTextForm.tsx— toggle + pattern/error message inputs with Zod client-side syntax validationTextFieldInput.tsx— live red border feedback + snackbar error on invalid save attemptTest plan
^BE0[0-9]{9}$as pattern andNot a valid Belgian VAT numberas error message, saveBE0123456789) — border clears, Enter saves successfully🤖 Generated with Claude Code