store dna all done

This commit is contained in:
CPM
2025-07-30 10:35:06 +05:30
commit b0399b39c6
157 changed files with 35444 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
import { toastError } from "./Toast";
export function validateNumber(val, type = '', showMsg = true) {
console.log(val, "type=======", type);
let isValid = true;
if (type.toLowerCase() == 'numeric' && val != '') {
let regex = new RegExp(/^\d+$/);
let isNUmeric = regex.test(val);
if (!isNUmeric) {
isValid = false;
if (showMsg) toastError('Alert', 'Please enter whole numbers only');
}
}
else if (type.toLowerCase() == 'decimal' && val != '') {
let regex = new RegExp(/^\d*\.?\d*$/);
let isNUmeric = regex.test(val);
if (!isNUmeric) {
isValid = false;
if (showMsg) toastError('Alert', 'Please enter decimal numbers only');
}
}
else if (type.toLowerCase() == 'text' && val != '') {
let regex = new RegExp(/^[a-zA-Z0-9@\s_.-]*$/);
let isNUmeric = regex.test(val);
if (!isNUmeric) {
isValid = false;
if (showMsg) toastError('Alert', 'Please enter only characters and digits');
}
}
else if (type.toLowerCase() === 'onlytext' && val !== '') {
let regex = /^[a-zA-Z\s]*$/; // ✅ allows only alphabets and space
const isAlpha = regex.test(val);
if (!isAlpha) {
isValid = false;
if (showMsg) toastError('Alert', 'Please enter only letters and spaces');
}
}
else if (type.toLowerCase() == 'textspc' && val != '') {
let regex = new RegExp(/^[a-zA-Z0-9\/-]*$/);
let isNUmeric = regex.test(val);
if (!isNUmeric) {
isValid = false;
if (showMsg) toastError('Alert', 'Please enter only characters and digits');
}
} else if (type.toLowerCase() == 'alphanumeric' && val != '') {
let regex = new RegExp(/^[a-zA-Z0-9]+$/);
let isNUmeric = regex.test(val);
if (!isNUmeric) {
isValid = false;
if (showMsg) toastError('Alert', 'Please enter only characters and digits');
}
}
return isValid;
}