Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 3x 17x 8x 9x 6x 3x 12x 3x | const COLOR_PATTERN = /^#[0-9A-Fa-f]{6}$/
/**
* Validates a ribbon `message` value (already known to be present).
* Accepts a plain non-empty string, or a language-keyed object with at
* least a non-empty `en` entry — other languages fall back to `en` when
* missing, mirroring the MultilingualInput UI component's semantics.
*
* @returns {string|null} An error message, or null when valid.
*/
function validateRibbonMessage(message) {
if (typeof message === 'string') {
return message.trim().length > 0 ? null : 'Message must not be empty'
}
if (message && typeof message === 'object' && !Array.isArray(message)) {
return typeof message.en === 'string' && message.en.trim().length > 0
? null
: 'Message must include a non-empty "en" translation'
}
return 'Message must be a string or a language-keyed object'
}
/**
* Validates a ribbon `color` value (already known to be present).
*
* @returns {string|null} An error message, or null when valid.
*/
function validateRibbonColor(color) {
return typeof color === 'string' && COLOR_PATTERN.test(color)
? null
: 'Color must be a 6-digit hex string (e.g. #dc3545)'
}
module.exports = { validateRibbonMessage, validateRibbonColor }
|