28 lines
726 B
TypeScript
28 lines
726 B
TypeScript
function validateForm(name : string, short : string, long : string, start : string, end : string,
|
|
register : string, location : string, online : any) : boolean | string {
|
|
// Assume good intention for now (internal use only)
|
|
if (!name) {
|
|
return "Event name is required.";
|
|
}
|
|
|
|
if (!short) {
|
|
return "Short description is required.";
|
|
}
|
|
|
|
if (!long) {
|
|
return "Long description is required.";
|
|
}
|
|
|
|
if (start && end) {
|
|
const startTime = new Date(start);
|
|
const endTime = new Date(end);
|
|
|
|
if (startTime > endTime) {
|
|
return "End time must be greater than or equal to start time."
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
export { validateForm }; |