{"action":"created","issue":{"url":"https://api.github.com/repos/aurelia/validatejs/issues/82","repository_url":"https://api.github.com/repos/aurelia/validatejs","labels_url":"https://api.github.com/repos/aurelia/validatejs/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/validatejs/issues/82/comments","events_url":"https://api.github.com/repos/aurelia/validatejs/issues/82/events","html_url":"https://github.com/aurelia/validatejs/issues/82","id":160317397,"number":82,"title":"Custom error messages on a per-field basis","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":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-06-15T00:58:42Z","updated_at":"2016-06-16T16:37:29Z","closed_at":null,"body":"How do we provide custom error messages on a per-field basis? This is particularly important for rules such as @format\r\nAlso, any custom message rule should inject the current options and value.\r\nIn treacherous we have `.withMessage` that takes either a string or a function with options and value passed in as parameters:\r\n```\r\n.forProperty(\"uRLAlias\").addRule(\"launchURL\",null).withMessage((v,o) => `${v} is not a valid launch URL`)\r\n.forProperty(\"exitURL\").addRule(\"regex\", url).withMessage((v,o) => `${v} is not a valid exit URL`)\r\n.forProperty(\"pauseURL\").addRule(\"regex\", url)\r\n```\r\nPerhaps `@validationMsg` can be used as a decorator, or/and\r\n```\r\n@format({ message = (v,o) => `${v} is not a valid exit URL`})\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/aurelia/validatejs/issues/comments/226541540","html_url":"https://github.com/aurelia/validatejs/issues/82#issuecomment-226541540","issue_url":"https://api.github.com/repos/aurelia/validatejs/issues/82","id":226541540,"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-06-16T16:37:29Z","updated_at":"2016-06-16T16:37:29Z","body":"@bblazely I think this is a problem with the ValidationController's logic.\r\n\r\nhttps://github.com/aurelia/validation/blob/master/src/validation-controller.js#L103\r\n\r\nhere's what's happening:\r\n\r\n1. data entry in the input causes the validate decorator to notify the controller (either on blur or immediately).\r\n2. the controller asks the validator to validate the binding's current object+property combination\r\n3. the validator returns an array of errors\r\n4. the controller uses the new array of errors in conjunction with the bindings existing set of errors and determines which errors need to be unrendered and which need to be re-rendered.  This is where the problem is.  The current logic says \"have I already rendered this error\", if yes, it skips it.  The check is based on the rule associated with the error.  So even though the new error has a different message, it's the same broken rule, so it's skipped by the current logic.\r\n\r\nI think the logic needs to change to \"unrender all existing errors and render all new errors\", so that the message stays up to date."}}
{"actor":{"display_login":"jdanyow"}}