Skip to main content

descriptionBasedOnPropertyValue

descriptionBasedOnPropertyValue(propertyValue, resourceDescriptionPropertyName, additionalResourceDescriptionPropertyName): (target, propertyName) => void

Property level decorator. Used to change how property is displayed. If we create an Order resource with status property, by default it will display waiting, pending or shipped. But when status becomes shipped we want to see shipping customer and date of shipping. We can add descriptionBasedOnPropertyValue decorator to status property:

 @descriptionBasedOnPropertyValue(
statusType.shipped,
orderProps.customer,
orderProps.shipDate,
)
status!: StatusType;

Now status can be displayed as waiting, pending and when it should display shipped it will display colin.b 03/27/25 instead.

Sets {@link ResourceMeta.description} (with value-based case conditions).

Parameters​

propertyValue​

unknown

property value

resourceDescriptionPropertyName​

string

property name

additionalResourceDescriptionPropertyName​

string

additional property name

Returns​

(target, propertyName): void

Parameters​

target​

unknown

propertyName​

string

Returns​

void