Common functions and utilities for tasks related to dynamic badges.
- Source:
Members
(inner, constant) compoundValueSchema :Joi
Joi schema for validating compound value. Checks if the compound value is of type individualValueSchema, array of individualValueSchema or empty array.
Type:
- Joi
- Source:
(inner, constant) httpErrors :object
Map of error codes and their corresponding error messages.
Type:
- object
- Source:
(inner, constant) individualValueSchema :Joi
Joi schema for validating individual value. Checks if the individual value is of type string or number.
Type:
- Joi
- Source:
Methods
(inner) renderDynamicBadge(attrs) → {object}
Handles rendering concerns of dynamic badges. Determines the label of the badge according to the tag and defaultLabel. Determines the message of the badge according to the prefix, suffix and value. Sets the color of the badge to blue.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
attrs |
object | Refer to individual attributes Properties
|
- Source:
Returns:
Badge with label, message and color properties
- Type
- object
(inner) transformAndValidate(attrs) → {object}
Look up the value in the data object by key and validate the value against compoundValueSchema.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
attrs |
object | Refer to individual attributes Properties
|
- Source:
Throws:
-
Error if Joi validation fails due to invalid or no schema
- Type
- InvalidResponse | Error
Returns:
Value if Joi validation is success
- Type
- object