Skip to main content

requiredIfPropHasValue

requiredIfPropHasValue(propertyName, value): (target, key) => void

Property level decorator. Specifies that the property is required if another property has a specific value. If we create User resource with contactId and contactNumber properties, but we want to require contactNumber only if contactId is 123, add @requiredIfPropHasValue("contactId", "123") decorator to contactNumber property.

Sets {@link PropertyMeta.requiredIfPropHasValue}.

Parameters

propertyName

string

The name of the property to check

value

unknown

The value of the property to check

Returns

(target, key): void

Parameters

target

object

key

string

Returns

void