I am using RESTier 0.4.0-rc2.
With OnUpdating... if the entity fails my custom validation logic I have no way to cancel the update, and return a custom error.
With CanUpdate... I can cancel the update by returning false, but there is no entity passed in to apply my custom logic to, and no way to provide a custom error.
Seems like a fundamental flaw, am I missing something?
Even you already have the answer, I would like to provide it for others.
If you want some customized logic for update validation, you can implement a class implements interface IChangeSetEntryValidator, validate in any logic you want, and then add logic like
DataModificationEntry dataModificationEntry = entry as DataModificationEntry;
var entity = dataModificationEntry.Entity;
// Customized validate logic and if error, add a error validation result.
validationResults.Add(new ChangeSetValidationResult()
{
Id = dataModificationEntry.EntitySetName+ dataModificationEntry.EntityKey,
Message = "Customized error",
Severity = ChangeSetValidationSeverity.Error,
Target = entity
});
You may find complete discussion at here