import { ValidatorFn } from '@angular/forms';

// const PASSWORD_PATTERN = /^[a-zA-Z0-9_-]*$/;

export function password(): ValidatorFn {
  return (control) => {
    const value = control?.value;
    if (value === null || value === undefined || String(value).length === 0) return null;

    if (value.length < 6) {
      return {
        minlength: {
          requiredLength: 6,
          actualLength: value.length,
        },
      };
    }
    return null;
    // return PASSWORD_PATTERN.test(String(value)) ? null : { password: 'معتبر نیست' };
  };
}
