How to use react-form-validator-core - 10 common examples

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 / lib / functions / validations.js View on Github external
}
exports.validateEndDate = validateEndDate;
react_form_validator_core_1.ValidatorForm.addValidationRule('validateEndDate', validateEndDate);
function startDateGreaterThanEndDate(startValue, endValue) {
    return endValue !== null ? validateEndDate(endValue, startValue) : true;
}
exports.startDateGreaterThanEndDate = startDateGreaterThanEndDate;
react_form_validator_core_1.ValidatorForm.addValidationRule('startDateGreaterThanEndDate', startDateGreaterThanEndDate);
react_form_validator_core_1.ValidatorForm.addValidationRule('isImage', function (value, extensionFile) {
    return imageRegex.test(extensionFile.toLowerCase());
});
react_form_validator_core_1.ValidatorForm.addValidationRule('atLeastOneLowerAndUpperCase', function (value) { return lettersRegex.test(value); });
react_form_validator_core_1.ValidatorForm.addValidationRule('atLeastOneNumber', function (value) { return numberRegex.test(value); });
react_form_validator_core_1.ValidatorForm.addValidationRule('atLeastOneSpecialCharacter', function (value) { return nonAlphanumericRegex.test(value); });
react_form_validator_core_1.ValidatorForm.addValidationRule('isPasswordMatch', function (value, comparedValue) { return value === comparedValue; });
react_form_validator_core_1.ValidatorForm.addValidationRule('password', function (value) { return !!value.match(passwordRegex); });
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);

react-form-validator-core

Core validator component for react forms.

MIT
Latest version published 23 days ago

Package Health Score

73 / 100
Full package analysis