import { i18n } from '@plugins/i18n';

export function innFormatRule(val: string): boolean | string {
  const pattern = /^(?!(?:10|12|13|15)$)[0-9]*$/;
  return val
    ? !pattern.test(String(val.length)) ||
        String(i18n.t('validation.organizations.invalidInnFormat'))
    : !val;
}

export function oktmoFormatRule(val: string): boolean | string {
  const pattern = /^(\d{8}|\d{11})$/;
  return val
    ? pattern.test(String(val)) ||
        String(i18n.t('validation.organizations.invalidOktmoFormat'))
    : !val;
}

export function urnFormatRule(val: string): boolean | string {
  const pattern = /^[0-9a-zA-Z]{6}$/;
  return val
    ? pattern.test(String(val)) ||
        String(i18n.t('validation.organizations.invalidUrnFormat'))
    : !val;
}
