@splitsoftware/splitio-commons
Version:
Split JavaScript SDK common components
19 lines (18 loc) • 727 B
JavaScript
import { __assign } from "tslib";
import { isObject } from '../lang';
import { validateKey } from './key';
import { validateAttributes } from './attributes';
import { ERROR_NOT_PLAIN_OBJECT } from '../../logger/constants';
export function validateTarget(log, maybeTarget, method) {
if (!isObject(maybeTarget)) {
log.error(ERROR_NOT_PLAIN_OBJECT, [method, 'target']);
return false;
}
var key = validateKey(log, maybeTarget.key, method);
if (key === false)
return false;
var attributes = validateAttributes(log, maybeTarget.attributes, method);
if (attributes === false)
return false;
return __assign(__assign({}, maybeTarget), { key: key, attributes: attributes });
}