import type { InputCommitPlugin } from '../../../primitives/input';

const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

export const createEmailValidatorPlugin =
  (): InputCommitPlugin =>
  ({ nextValue }) =>
    emailPattern.test(nextValue.trim());
