Skip to content

Commit

Permalink
Change email regex to a handcrafted one #180
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed Oct 7, 2023
1 parent 8bf2e93 commit 8ad42e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions library/src/validations/email/email.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('email', () => {
expect(validate('[email protected] (Joe Smith)').issues).toBeTruthy();
expect(validate('email@example').issues).toBeTruthy();
expect(validate('[email protected]').issues).toBeTruthy();
expect(validate('[email protected]').issues).toBeTruthy();
expect(validate('[email protected]').issues).toBeTruthy();
expect(validate('[email protected]').issues).toBeTruthy();
expect(validate('[email protected]').issues).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion library/src/validations/email/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getOutput, getPipeIssues } from '../../utils/index.ts';
*/
export function email<TInput extends string>(error?: ErrorMessage) {
return (input: TInput): PipeResult<TInput> =>
!/^(?!\.)(?!.*\.\.)([A-Z0-9_+-.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,}$/i.test(
!/^[\w+-]+(?:\.[\w+-]+)*@[A-Z0-9]+(?:(?:\.|-)[A-Z0-9]+)*\.[A-Z]{2,}$/i.test(
input
)
? getPipeIssues('email', error || 'Invalid email', input)
Expand Down

0 comments on commit 8ad42e7

Please sign in to comment.