{"action":"created","issue":{"url":"https://api.github.com/repos/eggjs/egg/issues/2734","repository_url":"https://api.github.com/repos/eggjs/egg","labels_url":"https://api.github.com/repos/eggjs/egg/issues/2734/labels{/name}","comments_url":"https://api.github.com/repos/eggjs/egg/issues/2734/comments","events_url":"https://api.github.com/repos/eggjs/egg/issues/2734/events","html_url":"https://github.com/eggjs/egg/issues/2734","id":335678529,"node_id":"MDU6SXNzdWUzMzU2Nzg1Mjk=","number":2734,"title":"egg-validate 如何自定义错误信息","user":{"login":"sjmlsxp","id":1901407,"node_id":"MDQ6VXNlcjE5MDE0MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/1901407?v=4","gravatar_id":"","url":"https://api.github.com/users/sjmlsxp","html_url":"https://github.com/sjmlsxp","followers_url":"https://api.github.com/users/sjmlsxp/followers","following_url":"https://api.github.com/users/sjmlsxp/following{/other_user}","gists_url":"https://api.github.com/users/sjmlsxp/gists{/gist_id}","starred_url":"https://api.github.com/users/sjmlsxp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjmlsxp/subscriptions","organizations_url":"https://api.github.com/users/sjmlsxp/orgs","repos_url":"https://api.github.com/users/sjmlsxp/repos","events_url":"https://api.github.com/users/sjmlsxp/events{/privacy}","received_events_url":"https://api.github.com/users/sjmlsxp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-26T06:39:53Z","updated_at":"2018-06-28T10:44:19Z","closed_at":null,"author_association":"NONE","body":"在使用egg-validate的时候，rule里面不能设置message\r\n系统提示的错误信息对用户不是很友好，如何自定义？"},"comment":{"url":"https://api.github.com/repos/eggjs/egg/issues/comments/400993470","html_url":"https://github.com/eggjs/egg/issues/2734#issuecomment-400993470","issue_url":"https://api.github.com/repos/eggjs/egg/issues/2734","id":400993470,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDk5MzQ3MA==","user":{"login":"thonatos","id":958063,"node_id":"MDQ6VXNlcjk1ODA2Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/958063?v=4","gravatar_id":"","url":"https://api.github.com/users/thonatos","html_url":"https://github.com/thonatos","followers_url":"https://api.github.com/users/thonatos/followers","following_url":"https://api.github.com/users/thonatos/following{/other_user}","gists_url":"https://api.github.com/users/thonatos/gists{/gist_id}","starred_url":"https://api.github.com/users/thonatos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thonatos/subscriptions","organizations_url":"https://api.github.com/users/thonatos/orgs","repos_url":"https://api.github.com/users/thonatos/repos","events_url":"https://api.github.com/users/thonatos/events{/privacy}","received_events_url":"https://api.github.com/users/thonatos/received_events","type":"User","site_admin":false},"created_at":"2018-06-28T10:44:19Z","updated_at":"2018-06-28T10:44:19Z","author_association":"MEMBER","body":"可以配置自定义规则\r\n\r\n```js\r\nconst parameter = app.validator;\r\nparameter.addRule(rule, check);\r\n\r\n// example\r\nfunction checkNumber(rule, value) {\r\n  if (typeof value !== 'number' || isNaN(value)) {\r\n    return this.t('should be a number');\r\n  }\r\n}\r\n\r\nvar TYPE_MAP = Parameter.TYPE_MAP = {\r\n  number: checkNumber,\r\n};\r\n```\r\n\r\n- https://github.com/node-modules/parameter"}}
{"actor":{"display_login":"thonatos"}}