{"action":"created","issue":{"url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/27","labels_url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/27/comments","events_url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/27/events","html_url":"https://github.com/offirgolan/ember-cp-validations/issues/27","id":106259159,"number":27,"title":"Dependent keys for custom validators","user":{"login":"mitchlloyd","id":15169,"avatar_url":"https://avatars.githubusercontent.com/u/15169?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchlloyd","html_url":"https://github.com/mitchlloyd","followers_url":"https://api.github.com/users/mitchlloyd/followers","following_url":"https://api.github.com/users/mitchlloyd/following{/other_user}","gists_url":"https://api.github.com/users/mitchlloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchlloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchlloyd/subscriptions","organizations_url":"https://api.github.com/users/mitchlloyd/orgs","repos_url":"https://api.github.com/users/mitchlloyd/repos","events_url":"https://api.github.com/users/mitchlloyd/events{/privacy}","received_events_url":"https://api.github.com/users/mitchlloyd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-14T02:21:24Z","updated_at":"2015-09-15T22:08:49Z","closed_at":null,"body":"Why not let custom validators use fields on the model at their discretion? This would let me support a lot of more \"meta\" type validations that I have had to deal with.\r\n\r\nLooking at https://github.com/offirgolan/ember-cp-validations/blob/v1.1.0/addon/utils/validations-factory.js#L176-L203 I can see that each built-in validator that needs custom dependent keys is hard-coded. Is a general API for this being discussed?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/comments/140560571","html_url":"https://github.com/offirgolan/ember-cp-validations/issues/27#issuecomment-140560571","issue_url":"https://api.github.com/repos/offirgolan/ember-cp-validations/issues/27","id":140560571,"user":{"login":"mitchlloyd","id":15169,"avatar_url":"https://avatars.githubusercontent.com/u/15169?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchlloyd","html_url":"https://github.com/mitchlloyd","followers_url":"https://api.github.com/users/mitchlloyd/followers","following_url":"https://api.github.com/users/mitchlloyd/following{/other_user}","gists_url":"https://api.github.com/users/mitchlloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchlloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchlloyd/subscriptions","organizations_url":"https://api.github.com/users/mitchlloyd/orgs","repos_url":"https://api.github.com/users/mitchlloyd/repos","events_url":"https://api.github.com/users/mitchlloyd/events{/privacy}","received_events_url":"https://api.github.com/users/mitchlloyd/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T22:08:49Z","updated_at":"2015-09-15T22:08:49Z","body":"@offirgolan One thing to keep in mind is that a validator may be dependent on another validator or a property on the model. For instance, the `dependent` validator uses `on` to specify a path to another validator and the `confirmation` validator uses `on` to specify a path to a `_model` attribute.\r\n\r\nOne use case I'm thinking of is \"make sure this model has least one hasMany model with this property\". The workaround today could be to create a computed property on the model:\r\n\r\n```\r\nhasAtLeastOneFeaturedPost(\"posts.@each.isFeatured\") {\r\n  return _.some(this.get('posts'), (p) => p.get('isFeatured'));\r\n}\r\n```\r\n\r\nAnd then validate that that is true, but it would be nice to be able to express that with just a validator.\r\n\r\n```\r\nvar Validations = buildValidations({\r\n  featuredPost: validator('has-some', { collection: 'posts', attribute: 'isFeatured' })\r\n});\r\n```"}}