Marks a field to trigger the onValidate callback when its value changes.
Useful for reacting to property changes from the editor or at runtime.

Your component must implement onValidate(property?: string) to receive notifications.

export class MyComponent extends Behaviour {
@serializable()
@validate()
color: Color = new Color(1, 0, 0);

onValidate(property?: string) {
if (property === "color") {
console.log("Color changed to:", this.color);
}
}
}
@validate(function(value) {
console.log("Setting speed to", value);
})
speed: number = 1;
  • Parameters

    • Optionalset: setter

      Optional custom setter called before the value is assigned

    • Optionalget: getter

      Optional custom getter called when the value is read

    Returns (target: any, propertyKey: string, descriptor?: undefined) => void