fix
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
Reference in New Issue
Block a user