Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
useOptions = options;
}
const validationMap = model.validations.validatableAttributes.reduce(
(o: any, attr: string) => {
o[attr] = true; // eslint-disable-line no-param-reassign
return o;
},
{},
);
const validateFn: ValidatorFunc = async params => {
const { validations } = await model.validateAttribute(params.key, params.newValue);
return validations.isValid ? true : validations.message;
};
return new Changeset(model, validateFn, validationMap, useOptions) as ChangesetDef;
}
init() {
this._super(...arguments);
this.changeset = new Changeset(model, lookupValidator(validation), validation);
},
export default function createChangeset(model, fn) {
let { validateFn, validationMap } = buildChangeset(model);
let _fn;
if (fn && typeof fn === 'function') {
_fn = function() {
return fn(...arguments, validateFn);
};
}
return new Changeset(model, _fn || validateFn, validationMap);
}
constructor() {
super(...arguments);
this.record = this.args.fileEntry || this.store.createRecord("file-entry");
this.changeset = new Changeset(
this.record,
lookupValidator(FileEntryValidations),
FileEntryValidations
);
this.changeset.account = this.args.account;
var token = ENV.CSRFToken;
this.changeset.csrfToken = token;
}
changeset: computed('fragment.type', function() {
const validations = VALIDATIONS[this.get('fragment.type')];
return new Changeset(
this.get('fragment'),
lookupValidator(validations),
validations
);
}),
export function changeset(
[obj, validations]: [object | Promise, ValidatorFunc],
options: Config = {}
): Changeset | Promise {
if (isChangeset(obj)) {
return obj;
}
if (isPromise(obj)) {
return Promise.resolve(obj).then((resolved: any) => new Changeset(resolved, validations, {}, options));
}
return new Changeset(obj, validations, {}, options);
}
return this.dispositions.map(disposition => new Changeset(disposition, lookupValidator(dispositionValidations), dispositionValidations));
}
constructor() {
super(...arguments);
this.record = this.args.folder || this.store.createRecord("folder");
this.isNewRecord = this.record.isNew;
this.changeset = new Changeset(
this.record,
lookupValidator(FolderValidations),
FolderValidations
);
if (this.isNewRecord && this.navService.selectedTeam)
this.changeset.team = this.navService.selectedTeam;
if (this.isNewRecord && isPresent(this.args.team)) {
this.changeset.team = this.args.team;
}
this.store.findAll("team").then((teams) => {
this.assignableTeams = teams;
});
}