How to use the ember-changeset/utils/computed/inflate 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
validateFn    /*: ValidatorFunc               */ = defaultValidatorFn,
  validationMap /*: { [string]: ValidatorFunc } */ = {},
  options       /*: Config                      */ = {}
) /*: Class */ {
  assert('Underlying object for changeset is missing', isPresent(obj));

  return EmberObject.extend(Evented, ({
    /**
     * Internal descriptor for changeset identification.
     */
    __changeset__: CHANGESET,

    changes: objectToArray(CHANGES, (c /*: Change */) => c.value, false),
    errors:  objectToArray(ERRORS, (e /*: Err */) => ({ value: e.value, validation: e.validation }), true),
    change:  inflate(CHANGES, c => c.value),
    error:   inflate(ERRORS, e => ({ value: e.value, validation: e.validation })),
    data:    readOnly(CONTENT),

    isValid:    isEmptyObject(ERRORS),
    isPristine: isEmptyObject(CHANGES),
    isInvalid:  not('isValid').readOnly(),
    isDirty:    not('isPristine').readOnly(),

    _bareChanges: transform(CHANGES, c => c.value),

    /*::
    _super() {},
    notifyPropertyChange() {},
    _content: {},
    _changes: {},
    _errors: {},
    _validator: defaultValidatorFn,
github poteto / ember-changeset / addon / index.js View on Github external
obj           /*: Object                      */,
  validateFn    /*: ValidatorFunc               */ = defaultValidatorFn,
  validationMap /*: { [string]: ValidatorFunc } */ = {},
  options       /*: Config                      */ = {}
) /*: Class */ {
  assert('Underlying object for changeset is missing', isPresent(obj));

  return EmberObject.extend(Evented, ({
    /**
     * Internal descriptor for changeset identification.
     */
    __changeset__: CHANGESET,

    changes: objectToArray(CHANGES, (c /*: Change */) => c.value, false),
    errors:  objectToArray(ERRORS, (e /*: Err */) => ({ value: e.value, validation: e.validation }), true),
    change:  inflate(CHANGES, c => c.value),
    error:   inflate(ERRORS, e => ({ value: e.value, validation: e.validation })),
    data:    readOnly(CONTENT),

    isValid:    isEmptyObject(ERRORS),
    isPristine: isEmptyObject(CHANGES),
    isInvalid:  not('isValid').readOnly(),
    isDirty:    not('isPristine').readOnly(),

    _bareChanges: transform(CHANGES, c => c.value),

    /*::
    _super() {},
    notifyPropertyChange() {},
    _content: {},
    _changes: {},
    _errors: {},