Function: resourcefulComputed()
ts
function resourcefulComputed<Schema>(
options: Partial<ComputedOptions> &
Partial<ResourcefulComputedAccessorDefinition<Schema>>,
): (target: any, propertyKey: string) => void;Decorator to define a resourceful computed accessor on a Lucid model property. Applies validation, metadata, and Lucid computed options.
Type Parameters
| Type Parameter | Default type |
|---|---|
Schema extends AnySchema<any> | ResourcefulPropertySchema |
Parameters
| Parameter | Type | Description |
|---|---|---|
options | Partial<ComputedOptions> & Partial<ResourcefulComputedAccessorDefinition<Schema>> | Resourceful computed accessor options and Lucid computed options. |
Returns
Property decorator function.
ts
(target: any, propertyKey: string): void;Parameters
| Parameter | Type |
|---|---|
target | any |
propertyKey | string |
Returns
void
Example
ts
import {
resourcefulComputed,
ResourcefulStringType,
} from "@nhtio/lucid-resourceful";
class User {
@resourcefulComputed({
type: ResourcefulStringType({ minLength: 1, maxLength: 100 }),
})
public get fullName() {
return `${this.firstName} ${this.lastName}`;
}
}