UNPKG

@decaf-ts/decorator-validation

Version:
39 lines (38 loc) 1.53 kB
/** * @description Property decorator factory for model attributes * @summary Creates a decorator that marks class properties as model attributes * * @param {string} [key=ModelKeys.ATTRIBUTE] - The metadata key under which to store the property name * @return {function(object, any?): void} - Decorator function that registers the property * @function prop * @category Property Decorators * * @mermaid * sequenceDiagram * participant D as Decorator * participant M as Model * * D->>M: Check if key exists * alt key exists * M-->>D: Return existing props array * else key doesn't exist * D->>M: Create new props array * end * D->>M: Check if property exists * alt property not in array * D->>M: Add property to array * end */ export declare function prop(key?: string): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any; /** * @description Combined property decorator factory for metadata and attribute marking * @summary Creates a decorator that both marks a property as a model attribute and assigns metadata to it * * @template V * @param {string} key - The metadata key * @param {V} value - The metadata value to associate with the property * @return {Function} - Combined decorator function * @function propMetadata * @category Property Decorators */ export declare function propMetadata<V>(key: string, value: V): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;