{"action":"created","issue":{"url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/229","repository_url":"https://api.github.com/repos/offirgolan/ember-cp-validations","labels_url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/229/labels{/name}","comments_url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/229/comments","events_url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/229/events","html_url":"https://github.com/offirgolan/ember-cp-validations/pull/229","id":162292062,"number":229,"title":"Allow computed properties in validator options","user":{"login":"xcambar","id":657654,"avatar_url":"https://avatars.githubusercontent.com/u/657654?v=3","gravatar_id":"","url":"https://api.github.com/users/xcambar","html_url":"https://github.com/xcambar","followers_url":"https://api.github.com/users/xcambar/followers","following_url":"https://api.github.com/users/xcambar/following{/other_user}","gists_url":"https://api.github.com/users/xcambar/gists{/gist_id}","starred_url":"https://api.github.com/users/xcambar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xcambar/subscriptions","organizations_url":"https://api.github.com/users/xcambar/orgs","repos_url":"https://api.github.com/users/xcambar/repos","events_url":"https://api.github.com/users/xcambar/events{/privacy}","received_events_url":"https://api.github.com/users/xcambar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-06-25T17:42:56Z","updated_at":"2016-06-26T00:02:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/offirgolan/ember-cp-validations/pulls/229","html_url":"https://github.com/offirgolan/ember-cp-validations/pull/229","diff_url":"https://github.com/offirgolan/ember-cp-validations/pull/229.diff","patch_url":"https://github.com/offirgolan/ember-cp-validations/pull/229.patch"},"body":"It is currently not possible in ember-cp-validations to use computed properties as options for the validators (eg, to compute what should be the minLength of the field).\r\n\r\nSimply by using `Ember.get(options, 'propertyName')` instead of `options.propertyName` in the validators, the implementor is allowed to benefit of computed properties.\r\n\r\nI hope you'll like it!"},"comment":{"url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/comments/228576675","html_url":"https://github.com/offirgolan/ember-cp-validations/pull/229#issuecomment-228576675","issue_url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/229","id":228576675,"user":{"login":"xcambar","id":657654,"avatar_url":"https://avatars.githubusercontent.com/u/657654?v=3","gravatar_id":"","url":"https://api.github.com/users/xcambar","html_url":"https://github.com/xcambar","followers_url":"https://api.github.com/users/xcambar/followers","following_url":"https://api.github.com/users/xcambar/following{/other_user}","gists_url":"https://api.github.com/users/xcambar/gists{/gist_id}","starred_url":"https://api.github.com/users/xcambar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xcambar/subscriptions","organizations_url":"https://api.github.com/users/xcambar/orgs","repos_url":"https://api.github.com/users/xcambar/repos","events_url":"https://api.github.com/users/xcambar/events{/privacy}","received_events_url":"https://api.github.com/users/xcambar/received_events","type":"User","site_admin":false},"created_at":"2016-06-26T00:02:36Z","updated_at":"2016-06-26T00:02:36Z","body":"> Is this really needed when all options can be functions which have access to all information needed to compute the necessary value?\r\n\r\nThis is correct, but isn't the \"option as function\" variation a computed property in disguise?\r\n\r\n> The options object is just a pojo which doesnt have any support for computed properties.\r\n\r\nCorrect again, but this PR allows POJOs **and more**. \r\n\r\nHere's my use case: I have a set of validation models (yes, as in Ember Data models). Those models have relationships and (computed) properties that depend on the relationships between them. As an example, \"maiden_name\" is only required when `gender === \"woman\"` and `married === true`. This is extremely easy to handle these use cases with computed properties (the framework does that for us).\r\n\r\nInstead of recomputing the array of validators whenever the conditions apply, it's much easier to pass objects with CPs to the validator and have the correct values applied during validation."}}
{"actor":{"display_login":"xcambar"}}