CEC-1965 Supplier update and approval (#162)
* CEC-1965 Supplier update and approval Fix calling connectedcars for no VINs Search sets table page to 0 * PR comments
This commit is contained in:
37
src/utils/validationSupplier.js
Normal file
37
src/utils/validationSupplier.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import validator from "email-validator";
|
||||
|
||||
export const validateSupplier = (supplier) => {
|
||||
if (supplier == null) {
|
||||
throw new Error("No supplier data");
|
||||
}
|
||||
|
||||
validateEmail(supplier.email);
|
||||
|
||||
if (supplier.contact.length === 0) {
|
||||
throw new Error("contact required");
|
||||
}
|
||||
|
||||
if (supplier.company.length === 0) {
|
||||
throw new Error("company required");
|
||||
}
|
||||
|
||||
if (supplier.address.length === 0) {
|
||||
throw new Error("address required");
|
||||
}
|
||||
|
||||
if (supplier.telephone.length === 0) {
|
||||
throw new Error("telephone required");
|
||||
}
|
||||
|
||||
if (supplier.program.length === 0) {
|
||||
throw new Error("program required");
|
||||
}
|
||||
|
||||
if (supplier.ecus.length === 0) {
|
||||
throw new Error("ecus required");
|
||||
}
|
||||
};
|
||||
|
||||
export const validateEmail = (email) => {
|
||||
if (!validator.validate(email)) throw new Error("invalid email");
|
||||
};
|
||||
Reference in New Issue
Block a user