mirror of
https://github.com/cpvalente/ontime.git
synced 2026-07-26 10:38:55 +00:00
fix: automation form validation
This commit is contained in:
committed by
Carlos Valente
parent
166160dda9
commit
701f24cece
@@ -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;
|
||||
|
||||
@@ -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> };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user