Skip to content

Commit

Permalink
Merge pull request #56 from mitra-deriv/update-regex-for-first-and-la…
Browse files Browse the repository at this point in the history
…st-name-validation

Mitra/KYC-1852/Update the regex for first and last name validation
  • Loading branch information
shayan-deriv authored Jun 25, 2024
2 parents 69d27fb + 6f1c9e1 commit ae968b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/constants/validation.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ export const patterns = {
*/
letterSymbols: /^[A-Za-z]+([a-zA-Z.' -])*[a-zA-Z.' -]+$/,
/**
* @regex /^(?!.*\s{2,})[\p{L}\s'.-]{2,50}$/u
* @description This pattern matches any string that contains 2-50 characters, starts and ends with valid characters (letters, whitespace, period, single quote, or hyphen).
* @regex /^(?!.*\s{2,})(?!\s)[\p{L}\s'.-]{1,50}$/u
* @description This pattern matches any string that contains 1 to 50 characters, starts and ends with valid characters (letters, whitespace, period, single quote, or hyphen).
* @example ValidationConstants.patterns.name.test("John Doe")
* @example ValidationConstants.patterns.name.test("John-Doe")
* @example ValidationConstants.patterns.name.test("John O'Doe")
* @example ValidationConstants.patterns.name.test("John O. Doe")
*/
name: /^(?!.*\s{2,})[\p{L}\s'.-]{2,50}$/u,
name: /^(?!.*\s{2,})(?!\s)[\p{L}\s'.-]{1,50}$/u,
/**
* @regex /[`~!@#$%^&*)(_=+[}{\]\\/";:?><|]+/
* @description This pattern matches any string that contains any of these characters: `~!@#$%^&*)(_=+[}{\]\\/";:?><|
Expand Down
4 changes: 2 additions & 2 deletions utils-docs/docs/Constants/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ letterSymbols: /^[A-Za-z]+([a-zA-Z.' -])*[a-zA-Z.' -]+$/;

### name

This pattern matches any string that contains **2-50** characters, starts and ends with valid characters (letters, whitespace, period, single quote, or hyphen).
This pattern matches any string that contains **1-50** characters, starts and ends with valid characters (letters, whitespace, period, single quote, or hyphen) and can not be single space or have two sequential spaces.

```JS
// @example ValidationConstants.patterns.name.test("John Doe")
// @example ValidationConstants.patterns.name.test("John-Doe")
// @example ValidationConstants.patterns.name.test("John O'Doe")
// @example ValidationConstants.patterns.name.test("John O. Doe")
name: /^(?!.*\s{2,})[\p{L}\s'.-]{2,50}$/u;
name: /^(?!.*\s{2,})(?!\s)[\p{L}\s'.-]{1,50}$/u;
```

### general
Expand Down

0 comments on commit ae968b9

Please sign in to comment.