Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
invalidErrorsChanged(jsonApiErrors) {
if (RECORD_DATA_ERRORS) {
this._clearErrorMessages();
let errors = errorsArrayToHash(jsonApiErrors);
let errorKeys = Object.keys(errors);
for (let i = 0; i < errorKeys.length; i++) {
this._addErrorMessageToAttribute(errorKeys[i], errors[errorKeys[i]]);
}
}
},
extractErrors(store, typeClass, payload, id) {
if (payload && typeof payload === 'object' && payload.errors) {
payload = errorsArrayToHash(payload.errors);
this.normalizeUsingDeclaredMapping(typeClass, payload);
typeClass.eachAttribute(name => {
let key = this.keyForAttribute(name, 'deserialize');
if (key !== name && payload[key] !== undefined) {
payload[name] = payload[key];
delete payload[key];
}
});
typeClass.eachRelationship(name => {
let key = this.keyForRelationship(name, 'deserialize');
if (key !== name && payload[key] !== undefined) {
payload[name] = payload[key];
delete payload[key];
errors._registerHandlers(
() => {
this.send('becameInvalid');
},
() => {
this.send('becameValid');
}
);
if (RECORD_DATA_ERRORS) {
let recordData = recordDataFor(this);
let jsonApiErrors;
if (recordData.getErrors) {
jsonApiErrors = recordData.getErrors();
if (jsonApiErrors) {
let errorsHash = errorsArrayToHash(jsonApiErrors);
let errorKeys = Object.keys(errorsHash);
for (let i = 0; i < errorKeys.length; i++) {
errors._add(errorKeys[i], errorsHash[errorKeys[i]]);
}
}
}
}
return errors;
}).readOnly(),