{"action":"created","issue":{"url":"https://api.github.com/repos/aurelia/validation/issues/328","repository_url":"https://api.github.com/repos/aurelia/validation","labels_url":"https://api.github.com/repos/aurelia/validation/issues/328/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/validation/issues/328/comments","events_url":"https://api.github.com/repos/aurelia/validation/issues/328/events","html_url":"https://github.com/aurelia/validation/issues/328","id":176777790,"number":328,"title":"DisplayNameKey or Metadata requirement?","user":{"login":"jsobell","id":834155,"avatar_url":"https://avatars.githubusercontent.com/u/834155?v=3","gravatar_id":"","url":"https://api.github.com/users/jsobell","html_url":"https://github.com/jsobell","followers_url":"https://api.github.com/users/jsobell/followers","following_url":"https://api.github.com/users/jsobell/following{/other_user}","gists_url":"https://api.github.com/users/jsobell/gists{/gist_id}","starred_url":"https://api.github.com/users/jsobell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsobell/subscriptions","organizations_url":"https://api.github.com/users/jsobell/orgs","repos_url":"https://api.github.com/users/jsobell/repos","events_url":"https://api.github.com/users/jsobell/events{/privacy}","received_events_url":"https://api.github.com/users/jsobell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aurelia/validation/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/aurelia/validation/milestones/3","html_url":"https://github.com/aurelia/validation/milestones/beta","labels_url":"https://api.github.com/repos/aurelia/validation/milestones/3/labels","id":1972169,"number":3,"title":"beta","description":"","creator":{"login":"jdanyow","id":1306747,"avatar_url":"https://avatars.githubusercontent.com/u/1306747?v=3","gravatar_id":"","url":"https://api.github.com/users/jdanyow","html_url":"https://github.com/jdanyow","followers_url":"https://api.github.com/users/jdanyow/followers","following_url":"https://api.github.com/users/jdanyow/following{/other_user}","gists_url":"https://api.github.com/users/jdanyow/gists{/gist_id}","starred_url":"https://api.github.com/users/jdanyow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdanyow/subscriptions","organizations_url":"https://api.github.com/users/jdanyow/orgs","repos_url":"https://api.github.com/users/jdanyow/repos","events_url":"https://api.github.com/users/jdanyow/events{/privacy}","received_events_url":"https://api.github.com/users/jdanyow/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":10,"state":"open","created_at":"2016-08-30T11:29:09Z","updated_at":"2016-09-16T00:30:33Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-09-13T23:35:05Z","updated_at":"2016-09-16T00:36:39Z","closed_at":null,"body":"A situation came up last night where @mroseboom wanted the following code:\r\n```\r\n.ensure((p: Person) => p.firstName).displayName('common.labels.firstname').required()\r\n```\r\nThe display name is translated, but it's clearly not using the property name as a key, and it's standard to have messages looked up by a key, so should we have the same thing for the DisplayName?\r\nIt currently only performs translation if a property name is supplied, but displayName is left null:\r\nhttps://github.com/aurelia/validation/blob/master/src/implementation/standard-validator.ts#L30\r\n\r\nIf we had a `.metadata('')` that allowed arbitrary data to be associated with the rule.property then I suppose people could leave the displayName blank and use that if they chose, and it would give lots of flexibility, but it's not very elegant.\r\n\r\nI considered `.displayNameKey()` in the same way we have a `messageKey`, but messageKeys are centralised, whereas the displayNameKey is simply a function intercept for multilingual purposes.\r\n\r\nPerhaps the easiest thing is to simply say\r\n```\r\n    if (displayName !== null || propertyName !== null) {\r\n      displayName = this.messageProvider.getDisplayName(displayName || propertyName);\r\n    }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/aurelia/validation/issues/comments/247491898","html_url":"https://github.com/aurelia/validation/issues/328#issuecomment-247491898","issue_url":"https://api.github.com/repos/aurelia/validation/issues/328","id":247491898,"user":{"login":"jdanyow","id":1306747,"avatar_url":"https://avatars.githubusercontent.com/u/1306747?v=3","gravatar_id":"","url":"https://api.github.com/users/jdanyow","html_url":"https://github.com/jdanyow","followers_url":"https://api.github.com/users/jdanyow/followers","following_url":"https://api.github.com/users/jdanyow/following{/other_user}","gists_url":"https://api.github.com/users/jdanyow/gists{/gist_id}","starred_url":"https://api.github.com/users/jdanyow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdanyow/subscriptions","organizations_url":"https://api.github.com/users/jdanyow/orgs","repos_url":"https://api.github.com/users/jdanyow/repos","events_url":"https://api.github.com/users/jdanyow/events{/privacy}","received_events_url":"https://api.github.com/users/jdanyow/received_events","type":"User","site_admin":false},"created_at":"2016-09-16T00:36:39Z","updated_at":"2016-09-16T00:36:39Z","body":"How about `.displayKey(key: string)`:\r\n\r\n```js\r\nValidationRules\r\n  .ensure('fname').displayKey('common.labels.firstName')\r\n    .required()\r\n    .minLength(3)\r\n  ...\r\n```\r\n\r\nThen we'd add a second argument to the message provider's `getDisplayName` method:\r\n```js\r\ngetDisplayName(propertyName: string, displayKey: string = null)\r\n```\r\n\r\nThoughts?\r\n\r\n"}}
{"actor":{"display_login":"jdanyow"}}