Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function changeset(
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: {},
export function changeset(
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: {},