How to use the mout/array/contains 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 / util.js View on Github external
// 値が設定されていればスルー。
  if (!isUndefined(val[name])) {
    return;
  }
  // defaultが設定されていればそれを使用する。
  if (!isUndefined(_default)) {
    val[name] = deepClone(_default);
    return;
  }
  // requiredがfalseならスルー。
  if (!required) {
    return;
  }
  // この時点で、入力必須だけどユーザ未入力な状態。可能な限り初期値を設定する。
  // inは"query", "header", "path", "formData", "body"のいずれか。
  if (contains(['formData', 'header', 'path', 'query'], _in)) {
    // 初期値設定不可能。
    return;
  }
  // この時点でinは必ず'body'になる。
  const schema = parameterObject.schema;
  if (contains(['boolean', 'integer', 'number', 'null', 'string'], schema.type)) {
    // 初期値設定不可能。
    return;
  }
  if (schema.type === 'object') {
    val[name] = {};
    generateDefaultProperties(schema, val[name]);
  }
  if (schema.type === 'array') {
    val = [];
    // 最低要素数が決まっていれば予めその要素数分を生成する。
github cam-inc / viron / src / components / viron-parameters / items / index.js View on Github external
export default function() {
  const schemaObject = this.schemaObject = this.opts.schemaobject;
  const itemsObject = this.opts.schemaobject.items;

  // ItemsObjectのtype値は"string", "number", "integer", "boolean", "array"のいずれか。
  // @see: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#fixed-fields-8
  // OAS2.0仕様通りではないが、"object"と"null"も許可する。
  this.isFormMode = contains(['boolean', 'integer', 'number', 'null', 'string'], itemsObject.type);
  this.isPropertiesMode = (itemsObject.type === 'object');
  this.isItemsMode = (itemsObject.type === 'array');
  if (this.isFormMode) {
    const formObject = deepClone(itemsObject);
    this.formObject = formObject;
  }
  if (this.isPropertiesMode) {
    const propertiesObject = deepClone(itemsObject);
    this.propertiesObject = propertiesObject;
  }
  if (this.isItemsMode) {
    const _itemsObject = deepClone(itemsObject.items);
    this.itemsObject = _itemsObject;
  }
  // エラー関連。
  this.errors = [];
github cam-inc / viron / src / components / viron-parameters / parameter / index.js View on Github external
this.propertiesObject = null;
  this.propertiesLabel = null;
  // Items関連。
  this.isItemsMode = false;
  this.schemaObject = null;
  this.itemsLabel = null;

  // 横幅調整。
  this.spreadStyle = 'spreadSmall';

  // 各変数を設定。
  // `in`の値は"query", "header", "path", "formData", "body"のいずれか。
  // @see: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object
  if (contains(['query', 'header', 'path', 'formData'], parameterObject.in)) {
    // `in`が`body`以外の場合、typeは必ず"string", "number", "integer", "boolean", "array", "fileのいずれかになる。
    if (contains(['string', 'number', 'integer', 'boolean', 'file'], parameterObject.type)) {
      this.isFormMode = true;
      const formObject = deepClone(parameterObject);
      delete formObject.in;
      this.formObject = formObject;
      this.spreadStyle = util.getSpreadStyle(formObject);
      // テーブルのprimaryKeyとnameが一致した場合は、入力フォームを強制的にdisableにします。
      if (parameterObject.in === 'path' && parameterObject.name === this.opts.primary) {
        this.isFormDisabled = true;
      }
    } else {
      // typeがarrayの場合。
      this.isItemsMode = true;
      const schemaObject = deepClone(parameterObject);
      this.schemaObject = schemaObject;
      this.itemsLabel = parameterObject.description || parameterObject.name;
      this.spreadStyle = 'spreadFull';
github cam-inc / viron / src / pages / viron-components / card / table / cell / index.js View on Github external
this.isEmphasised = (() => {
    const list = this.opts.column['x-emphasis'] || [];
    if (!list.length) {
      return false;
    }
    return contains(list, this.value);
  })();
}
github cam-inc / viron / src / components / organisms / viron-table / items.js View on Github external
this.sortedItems = sortBy(this.opts.items, item => {
    const labels = this.opts.tablelabels || [];
    if (contains(labels, item.key)) {
      return labels.indexOf(item.key);
    } else {
      return bigNumber;
    }
  });
  this.title = this.sortedItems[0].cell;
github cam-inc / viron / src / components / viron-parameters / properties / index.js View on Github external
this.getFormObject = (key, property) => {
    const ret = deepClone(property);
    ret.name = key;
    ret.required = contains(propertiesObject.required, key);
    return ret;
  };
github cam-inc / viron / src / store / getters / viron.js View on Github external
theme: state => {
    const defaultTheme = 'standard';
    if (!state.viron) {
      return defaultTheme;
    }
    if (!contains(['standard', 'midnight', 'terminal'], state.viron.theme)) {
      return defaultTheme;
    }
    return state.viron.theme;
  },
github cam-inc / viron / src / components / viron-parameters / properties / index.js View on Github external
this.getRequired = key => {
    return contains(propertiesObject.required, key);
  };
github cam-inc / viron / src / components / organisms / viron-table / items.js View on Github external
return filter(items, item => {
      return contains(columns, item.key);
    });
  };
github cam-inc / viron / src / components / viron-parameters / schema / index.js View on Github external
this.isPropertyRequired = key => {
    return contains(schemaObject.required || [], key);
  };