@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
40 lines • 1.85 kB
JavaScript
import { checkRegex } from './checkRegex';
import { regex } from './validations.constants';
export const minCharacter = (password, min) => password.length >= min;
export const maxCharacter = (password, max) => password.length <= max;
export const haveDigits = (password, parsedRepeat) => checkRegex(regex.digits, password, parsedRepeat);
export const haveLetters = (password, parsedRepeat) => checkRegex(regex.letters, password, parsedRepeat);
export const haveSymbols = (password, parsedRepeat) => checkRegex(regex.symbols, password, parsedRepeat);
export const noSpaces = (password) => !checkRegex(regex.spaces, password);
// TODO
export const upperCase = (password, parsedRepeat) => {
if (parsedRepeat && parsedRepeat > 1) {
let characterIndex = 0;
let upperCaseLetters = 0;
while (upperCaseLetters < parsedRepeat && characterIndex < password.length) {
const currentLetter = password.charAt(characterIndex);
if (currentLetter !== currentLetter.toLowerCase()) {
upperCaseLetters++;
}
characterIndex++;
}
return upperCaseLetters === parsedRepeat;
}
return password !== password.toLowerCase();
};
export const lowerCase = (password, parsedRepeat) => {
if (parsedRepeat && parsedRepeat > 1) {
let characterIndex = 0;
let lowerCaseLetters = 0;
while (lowerCaseLetters < parsedRepeat && characterIndex < password.length) {
const currentLetter = password.charAt(characterIndex);
if (currentLetter !== currentLetter.toUpperCase()) {
lowerCaseLetters++;
}
characterIndex++;
}
return lowerCaseLetters === parsedRepeat;
}
return password !== password.toUpperCase();
};
//# sourceMappingURL=generalPasswordValidation.js.map