How to use the ember-changeset/utils/validate-nested-obj function in ember-changeset

To help you get started, we’ve selected a few ember-changeset 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 poteto / ember-changeset / addon / index.js View on Github external
prepare(
      prepareChangesFn /*: ({ [string]: mixed }) => ({ [string]: mixed }) */
    ) /*: ChangesetDef */ {
      let changes /*: { [string]: mixed } */ = get(this, '_bareChanges');
      let preparedChanges = prepareChangesFn(changes);

      assert('Callback to `changeset.prepare` must return an object', isObject(preparedChanges));
      validateNestedObj('preparedChanges', preparedChanges);

      let newChanges /*: Changes */ = keys(preparedChanges).reduce((newObj, key) => {
        newObj[key] = new Change(preparedChanges[key]);
        return newObj;
      }, {});

      set(this, CHANGES, newChanges);
      return this;
    },
github poteto / ember-changeset / addon / index.js View on Github external
restore({ changes, errors } /*: Snapshot */) /*: ChangesetDef */ {
      validateNestedObj('snapshot.changes', changes);
      validateNestedObj('snapshot.errors',  errors);

      let newChanges /*: Changes */ = keys(changes).reduce((newObj, key) => {
        newObj[key] = new Change(changes[key]);
        return newObj;
      }, {});

      let newErrors /*: Errors */ = keys(errors).reduce((newObj, key) => {
        let e /*: ErrLike<*> */ = errors[key];
        newObj[key] = new Err(e.value, e.validation);
        return newObj;
      }, {});

      set(this, CHANGES, newChanges);
      set(this, ERRORS,  newErrors);

      (this /*: ChangesetDef */)._notifyVirtualProperties();
github poteto / ember-changeset / addon / index.js View on Github external
restore({ changes, errors } /*: Snapshot */) /*: ChangesetDef */ {
      validateNestedObj('snapshot.changes', changes);
      validateNestedObj('snapshot.errors',  errors);

      let newChanges /*: Changes */ = keys(changes).reduce((newObj, key) => {
        newObj[key] = new Change(changes[key]);
        return newObj;
      }, {});

      let newErrors /*: Errors */ = keys(errors).reduce((newObj, key) => {
        let e /*: ErrLike<*> */ = errors[key];
        newObj[key] = new Err(e.value, e.validation);
        return newObj;
      }, {});

      set(this, CHANGES, newChanges);
      set(this, ERRORS,  newErrors);