UNPKG

class-validator-multi-lang

Version:
22 lines 861 B
import { getGlobal } from '../utils/get-global.util'; const CLASS_VALIDATOR_MESSAGES = 'CLASS_VALIDATOR_MESSAGES'; export function getClassValidatorMessagesStorage() { const global = getGlobal(); if (!global[CLASS_VALIDATOR_MESSAGES]) { global[CLASS_VALIDATOR_MESSAGES] = {}; } return global[CLASS_VALIDATOR_MESSAGES]; } export function setClassValidatorMessages(messages) { const storageMessages = getClassValidatorMessagesStorage(); Object.keys(storageMessages).forEach(key => delete storageMessages[key]); Object.assign(storageMessages, messages); } export function getClassValidatorMessages() { return getClassValidatorMessagesStorage(); } export function getClassValidatorMessage(key) { const messages = getClassValidatorMessagesStorage(); return messages[key]; } //# sourceMappingURL=messages.storage.js.map