fix: api change custom fields (#1888)

* fix: validate nested custom path

* chore: add test
This commit is contained in:
Alex Christoffer Rasmussen
2025-11-27 09:15:02 +01:00
committed by GitHub
parent 80ec2d1186
commit f128f7acd2
3 changed files with 105 additions and 4 deletions
@@ -1,4 +1,4 @@
import { EndAction, TimeStrategy, TimerType, isKeyOfType } from 'ontime-types';
import { EndAction, OntimeEntry, TimeStrategy, TimerType, isKeyOfType } from 'ontime-types';
import { maxDuration } from 'ontime-utils';
import { coerceBoolean, coerceColour, coerceEnum, coerceNumber, coerceString } from '../utils/coerceType.js';
@@ -60,3 +60,14 @@ export function parseProperty(property: string, value: unknown) {
const parserFn = propertyConversion[property];
return { [property]: parserFn(value) };
}
export function isValidChangeProperty(target: OntimeEntry, property: string, value: unknown): boolean {
if (typeof property !== 'string') return false;
if (value === undefined) return false;
if (property.startsWith('custom:') && 'custom' in target) {
const customProperty = property.slice('custom:'.length);
if (!customProperty) return false;
return Object.hasOwn(target.custom, customProperty);
}
return Object.hasOwn(target, property);
}