How to use the mout/object/hasOwn function in mout

To help you get started, we’ve selected a few mout examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cam-inc / viron / src / components / viron-parameters / validator.js View on Github external
const additionalPropertiesAndPropertiesAndPatternProperties = (value, constraints) => {
  const result = ObjectAssign({}, resultTemplate);
  // Object。valueはSchemaObject。デフォルト空Object。
  let properties;// eslint-disable-line no-unused-vars
  // Object。valueはSchemaObject。デフォルト空Object。
  let patternProperties;// eslint-disable-line no-unused-vars
  // boolean もしくは SchemaObject。デフォルト空SchemaObject。
  let additionalProperties;// eslint-disable-line no-unused-vars
  if (!hasOwn(constraints, 'properties')) {
    properties = {};
  } else {
    properties = constraints.properties;
  }
  if (!hasOwn(constraints, 'patternProperties')) {
    patternProperties = {};
  } else {
    patternProperties = constraints.patternProperties;
  }
  if (!hasOwn(constraints, 'additionalProperties')) {
    additionalProperties = {};
  } else {
    additionalProperties = constraints.additionalProperties;
  }
  // @see: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.4.2
  if ((isBoolean(additionalProperties) && additionalProperties) || isObject(additionalProperties)) {
github cam-inc / viron / src / components / viron-parameters / validator.js View on Github external
const additionalItemsAndItems = (value, constraints) => {
  const result = ObjectAssign({}, resultTemplate);
  // SchemaObjectもしくは[SchemaObbject]。未定義時は空SchemaObject。
  let items;
  // booleanもしくはSchemaObject。
  let additionalItems;
  if (hasOwn(constraints, 'items')) {
    items = constraints.items;
  } else {
    items = {};
  }
  if (hasOwn(constraints, 'additionalItems')) {
    additionalItems = constraints.additionalItems;
  } else {
    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
github cam-inc / viron / src / components / viron-parameters / validator.js View on Github external
const allOf = (value, constraints) => {
  const result = ObjectAssign({}, resultTemplate);
  if (!hasOwn(constraints, 'allOf')) {
    return result;
  }
  const allOf = constraints.allOf;
  if (!isArray(allOf)) {
    return result;
  }
  // TODO:
  return result;
};
github cam-inc / viron / src / components / viron-parameters / validator.js View on Github external
const maximumAndExclusiveMaximum = (value, constraints) => {
  const result = ObjectAssign({}, resultTemplate);
  if (!hasOwn(constraints, 'maximum')) {
    return result;
  }
  const maximum = constraints.maximum;
  if (!isNumber(maximum)) {
    return result;
  }
  // 未定義時はfalse扱い。
  const exclusiveMaximum = !!constraints.exclusiveMaximum;
  if (exclusiveMaximum) {
    if (value >= maximum) {
      result.isValid = false;
      result.message = `${maximum}より小さい数値にして下さい。`;
      return result;
    }
  } else {
    if (value > maximum) {
github cam-inc / viron / src / components / viron-parameters / validator.js View on Github external
const maxItems = (value, constraints) => {
  const result = ObjectAssign({}, resultTemplate);
  if (!hasOwn(constraints, 'maxItems')) {
    return result;
  }
  const maxItems = constraints.maxItems;
  if (!isInteger(maxItems) || maxItems < 0) {
    return result;
  }
  if (value.length > maxItems) {
    result.isValid = false;
    result.message = `要素数を${maxItems}以下にして下さい。`;
    return result;
  }
  return result;
};
github cam-inc / viron / src / components / viron-parameters / validator.js View on Github external
const required = (value, constraints) => {
  const result = ObjectAssign({}, resultTemplate);
  if (!hasOwn(constraints, 'required')) {
    return result;
  }
  const required = constraints.required;
  if (!isArray(required) || !required.length) {
    return result;
  }
  forEach(required, key => {
    if (!hasOwn(value, key)) {
      result.isValid = false;
      const description = constraints.properties[key].description ? `(${constraints.properties[key].description})` : '';
      result.message = `要素に${key}${description}を含めて下さい。`;
    }
  });
  return result;
};
github cam-inc / viron / src / components / atoms / viron-wyswyg / tool-list-bullet.js View on Github external
const updateActiveStatus = range => {
    const formats = (!range ? {} : this.opts.quill.getFormat(range));
    this.isActive = hasOwn(formats, 'list') && formats['list'] === 'bullet';
    this.update();
  };
github cam-inc / viron / src / components / atoms / viron-wyswyg / tool-align-right.js View on Github external
const updateActiveStatus = range => {
    const formats = (!range ? {} : this.opts.quill.getFormat(range));
    this.isActive = (hasOwn(formats, 'align') && formats['align'] === 'right');
    this.update();
  };
github cam-inc / viron / src / core / validator.js View on Github external
forEach(constraint, key => {
    if (!hasOwn(value, key)) {
      result.isValid = false;
      result.message = `要素に${key}を含めて下さい。`;
    }
  });
  return result;
github cam-inc / viron / src / components / viron-parameters / validator.js View on Github external
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)}のいずれかの値を設定して下さい。`;
  }