How to use the react-form-validator-core.ValidatorForm.addValidationRule function in react-form-validator-core

To help you get started, we’ve selected a few react-form-validator-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unosquare / uno-react / src / functions / validations.ts View on Github external
function validateEndDate(endValue: string, startValue: string): boolean {
    const startDate = parseISO(startValue);
    const endDate = parseISO(endValue);
    return differenceInMinutes(endDate, startDate) > 0;
}

ValidatorForm.addValidationRule('validateEndDate', validateEndDate);

function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);

ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>
    imageRegex.test(extensionFile.toLowerCase()),
);

ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', (value: string) => lettersRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneNumber', (value: string) => numberRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', (value: string) => nonAlphanumericRegex.test(value));

ValidatorForm.addValidationRule(
    'isPasswordMatch',
    (value: string, comparedValue: string): boolean => value === comparedValue,
);

ValidatorForm.addValidationRule('password', (value: string): boolean => !!value.match(passwordRegex));
github unosquare / uno-react / src / functions / validations.ts View on Github external
return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);

ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>
    imageRegex.test(extensionFile.toLowerCase()),
);

ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', (value: string) => lettersRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneNumber', (value: string) => numberRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', (value: string) => nonAlphanumericRegex.test(value));

ValidatorForm.addValidationRule(
    'isPasswordMatch',
    (value: string, comparedValue: string): boolean => value === comparedValue,
);

ValidatorForm.addValidationRule('password', (value: string): boolean => !!value.match(passwordRegex));

export { startDateGreaterThanEndDate, ValidatorForm, validateEndDate };
github unosquare / uno-react / src / functions / validations.ts View on Github external
const maxInteger = +Number(maxInt);

    return valueReal >= 0 && valueReal <= maxInteger;
}

ValidatorForm.addValidationRule('isNotAllBlanks', isNotAllBlanks);

ValidatorForm.addValidationRule('maxNaturalNumber', maxNaturalNumber);

function validateEndDate(endValue: string, startValue: string): boolean {
    const startDate = parseISO(startValue);
    const endDate = parseISO(endValue);
    return differenceInMinutes(endDate, startDate) > 0;
}

ValidatorForm.addValidationRule('validateEndDate', validateEndDate);

function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);

ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>
    imageRegex.test(extensionFile.toLowerCase()),
);

ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', (value: string) => lettersRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneNumber', (value: string) => numberRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', (value: string) => nonAlphanumericRegex.test(value));
github unosquare / uno-react / src / functions / validations.ts View on Github external
function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);

ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>
    imageRegex.test(extensionFile.toLowerCase()),
);

ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', (value: string) => lettersRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneNumber', (value: string) => numberRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', (value: string) => nonAlphanumericRegex.test(value));

ValidatorForm.addValidationRule(
    'isPasswordMatch',
    (value: string, comparedValue: string): boolean => value === comparedValue,
);

ValidatorForm.addValidationRule('password', (value: string): boolean => !!value.match(passwordRegex));

export { startDateGreaterThanEndDate, ValidatorForm, validateEndDate };
github unosquare / uno-react / src / functions / validations.ts View on Github external
ValidatorForm.addValidationRule('maxNaturalNumber', maxNaturalNumber);

function validateEndDate(endValue: string, startValue: string): boolean {
    const startDate = parseISO(startValue);
    const endDate = parseISO(endValue);
    return differenceInMinutes(endDate, startDate) > 0;
}

ValidatorForm.addValidationRule('validateEndDate', validateEndDate);

function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);

ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>
    imageRegex.test(extensionFile.toLowerCase()),
);

ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', (value: string) => lettersRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneNumber', (value: string) => numberRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', (value: string) => nonAlphanumericRegex.test(value));

ValidatorForm.addValidationRule(
    'isPasswordMatch',
    (value: string, comparedValue: string): boolean => value === comparedValue,
);
github unosquare / uno-react / src / functions / validations.ts View on Github external
ValidatorForm.addValidationRule('validateEndDate', validateEndDate);

function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);

ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>
    imageRegex.test(extensionFile.toLowerCase()),
);

ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', (value: string) => lettersRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneNumber', (value: string) => numberRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', (value: string) => nonAlphanumericRegex.test(value));

ValidatorForm.addValidationRule(
    'isPasswordMatch',
    (value: string, comparedValue: string): boolean => value === comparedValue,
);

ValidatorForm.addValidationRule('password', (value: string): boolean => !!value.match(passwordRegex));

export { startDateGreaterThanEndDate, ValidatorForm, validateEndDate };
github unosquare / uno-react / src / functions / validations.ts View on Github external
return differenceInMinutes(endDate, startDate) > 0;
}

ValidatorForm.addValidationRule('validateEndDate', validateEndDate);

function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);

ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>
    imageRegex.test(extensionFile.toLowerCase()),
);

ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', (value: string) => lettersRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneNumber', (value: string) => numberRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', (value: string) => nonAlphanumericRegex.test(value));

ValidatorForm.addValidationRule(
    'isPasswordMatch',
    (value: string, comparedValue: string): boolean => value === comparedValue,
);

ValidatorForm.addValidationRule('password', (value: string): boolean => !!value.match(passwordRegex));

export { startDateGreaterThanEndDate, ValidatorForm, validateEndDate };
github unosquare / uno-react / src / functions / validations.ts View on Github external
ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>
    imageRegex.test(extensionFile.toLowerCase()),
);

ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', (value: string) => lettersRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneNumber', (value: string) => numberRegex.test(value));

ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', (value: string) => nonAlphanumericRegex.test(value));

ValidatorForm.addValidationRule(
    'isPasswordMatch',
    (value: string, comparedValue: string): boolean => value === comparedValue,
);

ValidatorForm.addValidationRule('password', (value: string): boolean => !!value.match(passwordRegex));

export { startDateGreaterThanEndDate, ValidatorForm, validateEndDate };
github unosquare / uno-react / src / functions / validations.ts View on Github external
const nonAlphanumericRegex = new RegExp('^(?=.*[^da-zA-Z0-9])');
const imageRegex = new RegExp('.(jpe?g|png)');
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!_%*.?&])([A-Za-z\d$@$!%*?&]|[^ ]){8,}$/;

export function isNotAllBlanks(value: string, minlength: number): boolean {
    return value.replace(/\s/g, '').length >= minlength;
}

export function maxNaturalNumber(value: string, maxInt: any): boolean {
    const valueReal = +Number(value);
    const maxInteger = +Number(maxInt);

    return valueReal >= 0 && valueReal <= maxInteger;
}

ValidatorForm.addValidationRule('isNotAllBlanks', isNotAllBlanks);

ValidatorForm.addValidationRule('maxNaturalNumber', maxNaturalNumber);

function validateEndDate(endValue: string, startValue: string): boolean {
    const startDate = parseISO(startValue);
    const endDate = parseISO(endValue);
    return differenceInMinutes(endDate, startDate) > 0;
}

ValidatorForm.addValidationRule('validateEndDate', validateEndDate);

function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);
github unosquare / uno-react / src / functions / validations.ts View on Github external
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!_%*.?&])([A-Za-z\d$@$!%*?&]|[^ ]){8,}$/;

export function isNotAllBlanks(value: string, minlength: number): boolean {
    return value.replace(/\s/g, '').length >= minlength;
}

export function maxNaturalNumber(value: string, maxInt: any): boolean {
    const valueReal = +Number(value);
    const maxInteger = +Number(maxInt);

    return valueReal >= 0 && valueReal <= maxInteger;
}

ValidatorForm.addValidationRule('isNotAllBlanks', isNotAllBlanks);

ValidatorForm.addValidationRule('maxNaturalNumber', maxNaturalNumber);

function validateEndDate(endValue: string, startValue: string): boolean {
    const startDate = parseISO(startValue);
    const endDate = parseISO(endValue);
    return differenceInMinutes(endDate, startDate) > 0;
}

ValidatorForm.addValidationRule('validateEndDate', validateEndDate);

function startDateGreaterThanEndDate(startValue: string, endValue: string): boolean {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}

ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);

ValidatorForm.addValidationRule('isImage', (value: string, extensionFile: string) =>

react-form-validator-core

Core validator component for react forms.

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis