UNPKG

cloudinary-video-player

Version:
78 lines (70 loc) 2.74 kB
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.js'; import { r as requireIsFunction, i as isObject } from './video-player.const.js'; var isFunctionExports = requireIsFunction(); var isFunction = /*@__PURE__*/getDefaultExportFromCjs(isFunctionExports); const getValidatorItem = validator => isFunction(validator) ? validator() : validator; /** * check if a value is valid or not * @param {object | function} validator - a config object * @param {any} value * @param {key} string * @returns boolean - using the validators to check if the value is a valid value or not */ const isValueValid = (validator, value, configPropertyName) => { const validatorItem = getValidatorItem(validator); const isValid = validatorItem.value(value); if (!isValid) { console.error(`cloudinary video player: ${validatorItem.message(configPropertyName)}`); } return isValid; }; /** * check if a configuration object is valid or not * @param {object} config - a config object * @param {object} validators * @returns boolean - true is the configuration object is valid and false if it is not */ const isValidConfig = (config, validators) => { if (isObject(validators)) { for (let key in config) { if (Object.prototype.hasOwnProperty.call(validators, key)) { const configValue = config[key]; const validatorValue = validators[key]; const isConfigObject = isObject(configValue); if (isConfigObject && !isValidConfig(configValue, validatorValue)) { return false; } else if (!isConfigObject && !isValueValid(validatorValue, configValue, key)) { return false; } } } } return true; }; /** * check if a configuration object is valid or not * @param {object} config - a config object * @returns boolean - true is the configuration object is valid and false if it is not */ const isValidPlayerConfig = async config => { return import(/* webpackChunkName: "debug" */'./debug.js').then(function (n) { return n.v; }).then(_ref => { let { playerValidators } = _ref; return isValidConfig(config, playerValidators); }); }; /** * check if a configuration object is valid or not * @param {object} config - a config object * @returns boolean - true is the configuration object is valid and false if it is not */ const isValidSourceConfig = config => { return import(/* webpackChunkName: "debug" */'./debug.js').then(function (n) { return n.v; }).then(_ref2 => { let { sourceValidators } = _ref2; return isValidConfig(config, sourceValidators); }); }; export { isValidPlayerConfig as a, isValidSourceConfig as b, isValueValid as c, getValidatorItem as g, isFunction as i };