This commit is contained in:
nasir@endelospay.com
2024-06-07 04:02:32 +05:00
parent bff5e31c09
commit e024a459c0
10 changed files with 624 additions and 14 deletions

View File

@@ -142,3 +142,31 @@ export const requiredExcelValidator = value => {
return !!String(value).trim().length || 'Email is required'
}
export const requiredAmountFloat = (value) => {
// Check if the value is null, undefined, an empty array, or false
if (isNullOrUndefined(value) || isEmptyArray(value) || value === false) {
return 'Amount field is required';
}
// Check if the value is a valid float number
if (!isFloat(value)) {
return 'Please enter a valid amount';
}
// Additional checks as needed...
// Return true if the value passes validation
return true;
};
// Check if a value is a valid float number
const isFloat = (value) => {
if (typeof value !== 'number' && typeof value !== 'string') {
return false;
}
// Use regex to match a valid float number (including negatives and decimals)
return /^-?\d*\.?\d+$/.test(value);
};