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

export const createMultiInputValidatorPlugin =
  (): InputCommitPlugin =>
  ({ nextValue }) => {
    const digits = nextValue.replace(/\D/g, '');
    return digits.length === 10 || digits.length === 11;
  };

export const createMultiSegmentValidatorPlugin =
  (segmentLength: 3 | 4): InputCommitPlugin =>
  ({ nextValue }) => {
    const digits = nextValue.replace(/\D/g, '');
    return digits.length === segmentLength;
  };
