Skip to content

Commit

Permalink
Don't export internal validators
Browse files Browse the repository at this point in the history
  • Loading branch information
wlee221 committed Nov 7, 2022
1 parent 120e814 commit 7a2254c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/ui/src/helpers/accountSettings/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ import { hasAllowedSpecialChars } from '../authenticator';
import { getPasswordSettings } from './utils';

// TODO: consolidate these with Authenticator validators
export const minLength: MinLengthValidator = (minLength: number) => {
const minLength: MinLengthValidator = (minLength: number) => {
return (field: string) => {
if (field?.length < minLength) {
return `Password must have at least ${minLength} characters`;
}
};
};

export const hasLowerCase: FieldValidator = (field: string) => {
const hasLowerCase: FieldValidator = (field: string) => {
if (!/[a-z]/.test(field)) {
return 'Password must have lower case letters';
}
};

export const hasUpperCase: FieldValidator = (field: string) => {
const hasUpperCase: FieldValidator = (field: string) => {
if (!/[a-z]/.test(field)) {
return 'Password must have lower case letters';
}
};

export const hasNumbers: FieldValidator = (field: string) => {
const hasNumbers: FieldValidator = (field: string) => {
if (!/[0-9]/.test(field)) {
return 'Password must have numbers';
}
};

export const hasSpecialChars = (field: string) => {
const hasSpecialCharacters = (field: string) => {
if (!hasAllowedSpecialChars(field)) {
return 'Password must have special characters';
}
};

export const confirmPasswordMatch: ConfirmPasswordValidator = (
const confirmPasswordMatch: ConfirmPasswordValidator = (
newPassword,
confirmPassword
) => {
Expand Down Expand Up @@ -74,7 +74,7 @@ export const getDefaultPasswordValidator = (): FieldValidator[] => {
break;
}
case 'REQUIRES_SYMBOLS': {
validators.push(hasSpecialChars);
validators.push(hasSpecialCharacters);
break;
}
default: {
Expand Down

0 comments on commit 7a2254c

Please sign in to comment.