Skip to content

Commit

Permalink
Improve handcrafted email regex #180
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Groß <[email protected]>
  • Loading branch information
fabian-hiller and kurtextrem committed Oct 8, 2023
1 parent 8ad42e7 commit d255ac0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions library/src/validations/email/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import { getOutput, getPipeIssues } from '../../utils/index.ts';
*/
export function email<TInput extends string>(error?: ErrorMessage) {
return (input: TInput): PipeResult<TInput> =>
!/^[\w+-]+(?:\.[\w+-]+)*@[A-Z0-9]+(?:(?:\.|-)[A-Z0-9]+)*\.[A-Z]{2,}$/i.test(
input
)
!/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/i.test(input)
? getPipeIssues('email', error || 'Invalid email', input)
: getOutput(input);
}

0 comments on commit d255ac0

Please sign in to comment.