@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
51 lines • 2.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.lowerCase = exports.upperCase = exports.noSpaces = exports.haveSymbols = exports.haveLetters = exports.haveDigits = exports.maxCharacter = exports.minCharacter = void 0;
const checkRegex_1 = require("./checkRegex");
const validations_constants_1 = require("./validations.constants");
const minCharacter = (password, min) => password.length >= min;
exports.minCharacter = minCharacter;
const maxCharacter = (password, max) => password.length <= max;
exports.maxCharacter = maxCharacter;
const haveDigits = (password, parsedRepeat) => (0, checkRegex_1.checkRegex)(validations_constants_1.regex.digits, password, parsedRepeat);
exports.haveDigits = haveDigits;
const haveLetters = (password, parsedRepeat) => (0, checkRegex_1.checkRegex)(validations_constants_1.regex.letters, password, parsedRepeat);
exports.haveLetters = haveLetters;
const haveSymbols = (password, parsedRepeat) => (0, checkRegex_1.checkRegex)(validations_constants_1.regex.symbols, password, parsedRepeat);
exports.haveSymbols = haveSymbols;
const noSpaces = (password) => !(0, checkRegex_1.checkRegex)(validations_constants_1.regex.spaces, password);
exports.noSpaces = noSpaces;
// TODO
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();
};
exports.upperCase = upperCase;
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();
};
exports.lowerCase = lowerCase;
//# sourceMappingURL=generalPasswordValidation.js.map