fix: automation form validation

This commit is contained in:
Carlos Valente
2025-12-21 15:28:35 +01:00
committed by Carlos Valente
parent 166160dda9
commit 701f24cece
7 changed files with 66 additions and 21 deletions
@@ -98,6 +98,7 @@ export type OntimeAction =
text?: string;
visible?: boolean;
}
// TODO: when setting a secondary source of type secondary we could specify a value to it
| {
type: 'ontime';
action: OntimeMessageSecondary;
+13
View File
@@ -17,6 +17,19 @@ export function getPropertyFromPath<T extends object>(path: string, obj: T): unk
return result;
}
/**
* Whether an object is empty
*/
export function isObjectEmpty(obj: object): boolean {
return Object.keys(obj).length === 0;
}
/**
* Removes a copy of the object without the properties which have undefined values
*/
export function withoutUndefinedValues<T extends Record<string, unknown>>(
obj: T,
): { [K in keyof T]: Exclude<T[K], undefined> } {
Object.keys(obj).forEach((key) => obj[key] === undefined && delete obj[key]);
return obj as { [K in keyof T]: Exclude<T[K], undefined> };
}