{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1226","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1226/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1226/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1226/events","html_url":"https://github.com/strongloop/loopback/issues/1226","id":62786401,"number":1226,"title":"afterValidate operation hook","user":{"login":"drish","id":1730156,"avatar_url":"https://avatars.githubusercontent.com/u/1730156?v=3","gravatar_id":"","url":"https://api.github.com/users/drish","html_url":"https://github.com/drish","followers_url":"https://api.github.com/users/drish/followers","following_url":"https://api.github.com/users/drish/following{/other_user}","gists_url":"https://api.github.com/users/drish/gists{/gist_id}","starred_url":"https://api.github.com/users/drish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drish/subscriptions","organizations_url":"https://api.github.com/users/drish/orgs","repos_url":"https://api.github.com/users/drish/repos","events_url":"https://api.github.com/users/drish/events{/privacy}","received_events_url":"https://api.github.com/users/drish/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars.githubusercontent.com/u/1140553?v=3","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"milestone":null,"comments":15,"created_at":"2015-03-18T20:04:38Z","updated_at":"2015-04-08T06:48:00Z","closed_at":"2015-04-08T06:48:00Z","body":"Hello guys.\r\n\r\nThe docs say the current version does not support `afterValidate` hook, but what about the case where I need to manipulate data after it is validated ?\r\nFor example, after all my fields are validated I'd like to encrypt some of them and persist into datastore. \r\n\r\nCommon hook `model.afterValidate` is deprecated.\r\n\r\nThanks in advance."},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/90822215","html_url":"https://github.com/strongloop/loopback/issues/1226#issuecomment-90822215","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/1226","id":90822215,"user":{"login":"bajtos","id":1140553,"avatar_url":"https://avatars.githubusercontent.com/u/1140553?v=3","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"created_at":"2015-04-08T06:48:00Z","updated_at":"2015-04-08T06:48:00Z","body":"> > * load: whenever an instances is loaded from the datasource\r\n> > * save: in-between before save and saving through the DS, just after validation is performed\r\n\r\n> Yes, this is exactly what I had in mind. I feel save may be confusing in the context of before save and after save. How about the name persist?\r\n\r\nLet's move the discussion here: https://github.com/strongloop/loopback-datasource-juggler/issues/559\r\n\r\n> > error: whenever an error occurs along the way ({ ctx.error: ..., ctx.type: ... } will be set to differentiate)\r\n\r\n> +1 for ctx.error. What value do you expect in ctx.type? Are you proposing to trigger the same error hook for all operations, including find and delete?\r\n\r\nLet's move the discussion to a standalone issue: https://github.com/strongloop/loopback-datasource-juggler/issues/560\r\n\r\n---\r\n\r\n@drish I am closing this issue in favour of https://github.com/strongloop/loopback-datasource-juggler/issues/441 and https://github.com/strongloop/loopback-datasource-juggler/issues/559. Feel free to reopen if you disagree."}}