mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 10:53:51 +00:00
fix: api change custom fields (#1888)
* fix: validate nested custom path * chore: add test
This commit is contained in:
committed by
GitHub
parent
80ec2d1186
commit
f128f7acd2
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user