Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const definitions = (value, constraints) => {
const result = ObjectAssign({}, resultTemplate);
if (!hasOwn(constraints, 'definitions')) {
return result;
}
const definitions = constraints.definitions;
if (!isArray(definitions)) {
return result;
}
// TODO:
return result;
};
const oneOf = (value, constraints) => {
const result = ObjectAssign({}, resultTemplate);
if (!hasOwn(constraints, 'oneOf')) {
return result;
}
const oneOf = constraints.oneOf;
if (!isArray(oneOf)) {
return result;
}
// TODO:
return result;
};
additionalItems = {};
}
// itemsが未定義もしくはオブジェクトならばvalidate結果は常にOK。
// @see: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.1.2
if (isUndefined(items) || isObject(items)) {
return result;
}
// additionalItemsがBooleanのtrueもしくはobjectならばvalidate結果は常にOK。
// @see: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.1.2
if ((isBoolean(additionalItems) && additionalItems) || isObject(additionalItems)) {
return result;
}
// additionalItemsがBooleanのfalseでありitemsがarrayの場合、
// value配列の長さがitemsの長さ以下ならばvalidate結果はOK。
// @see: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.1.3
if ((isBoolean(additionalItems) && !additionalItems) && isArray(items)) {
if (value.length <= items.length) {
return result;
}
}
result.isValid = false;
result.message = `要素数を${items.length}以下にして下さい。`;
return result;
};
this.getFilteredItems = () => {
const items = this.sortedItems;
const columns = this.opts.selectedtablecolumns;
if (!isArray(columns) || !columns.length) {
return items;
}
return filter(items, item => {
return contains(columns, item.key);
});
};
forOwn(data, (val, key) => {
ret += `<label class="${BlockName}__pair">`;
if (isObject(val) || isArray(val)) {
ret += `<input type="checkbox" class="${BlockName}__toggle">`;
}
ret += `<div class="${BlockName}__key">${key}:</div>`;
ret += `<div class="${BlockName}__value">${renderHtml(val)}</div>`;
if (isObject(val)) {
ret += `<div class="${BlockName}__dots">{...}</div>`;
}
if (isArray(val)) {
ret += `<div class="${BlockName}__dots">[...]</div>`;
}
ret += '</label>';
});
ret += '';
const validate = data => {
if (!isArray(data)) {
return 'レスポンスデータが配列ではありません。';
}
if (!data.length) {
return '0件です。';
}
if (!isObject(data[0])) {
return '行データがオブジェクトではありません。';
}
return null;
};
const trim = val => {
let loop;
if (isObject(val)) {
loop = forOwn;
} else if (isArray(val)) {
loop = forEach;
} else {
return;
}
loop(val, (v, k) => {
if (isNull(v)) {
val[k] = undefined;
}
if (isObject(v) || isArray(v)) {
trim(v);
}
});
};
trim(ret);
const generateDefaultItem = itemsObject => {
if (isArray(itemsObject)) {
itemsObject = itemsObject[0];
}
if (contains(['boolean', 'integer', 'number', 'null', 'string'], itemsObject.type)) {
return itemsObject.default;
}
if (itemsObject.type === 'object' && itemsObject) {
return generateDefaultProperties(itemsObject);
}
if (itemsObject.type === 'array') {
if (!itemsObject.required) {
return undefined;
}
const ret = [];
const minItems = itemsObject.minItems;
if (isInteger(minItems) && minItems > 0) {
times(minItems, () => {
const _enum = (value, constraints) => {
const result = ObjectAssign({}, resultTemplate);
if (!hasOwn(constraints, 'enum')) {
return result;
}
const _enum = constraints.enum;
if (!isArray(_enum)) {
return result;
}
let isFound = false;
forEach(_enum, item => {
if (value === item) {
isFound = true;
}
});
if (!isFound) {
result.isValid = false;
result.message = `${JSON.stringify(_enum)}のいずれかの値を設定して下さい。`;
}
return result;
};
forEach(types, type => {
switch (type) {
case 'integer':
case 'number':
if (isNumber(value)) {
isValid = true;
}
break;
case 'string':
if (isString(value)) {
isValid = true;
}
break;
case 'array':
if (isArray(value)) {
isValid = true;
}
break;
case 'object':
if (isObject(value)) {
isValid = true;
}
break;
case 'boolean':
if (isBoolean(value)) {
isValid = true;
}
break;
case 'null':
if (isNull(value)) {
isValid = true;