{"action":"created","issue":{"url":"https://api.github.com/repos/serverless/serverless/issues/1978","repository_url":"https://api.github.com/repos/serverless/serverless","labels_url":"https://api.github.com/repos/serverless/serverless/issues/1978/labels{/name}","comments_url":"https://api.github.com/repos/serverless/serverless/issues/1978/comments","events_url":"https://api.github.com/repos/serverless/serverless/issues/1978/events","html_url":"https://github.com/serverless/serverless/pull/1978","id":173869374,"number":1978,"title":"Add custom validation for plugin options","user":{"login":"horike37","id":1301012,"avatar_url":"https://avatars.githubusercontent.com/u/1301012?v=3","gravatar_id":"","url":"https://api.github.com/users/horike37","html_url":"https://github.com/horike37","followers_url":"https://api.github.com/users/horike37/followers","following_url":"https://api.github.com/users/horike37/following{/other_user}","gists_url":"https://api.github.com/users/horike37/gists{/gist_id}","starred_url":"https://api.github.com/users/horike37/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/horike37/subscriptions","organizations_url":"https://api.github.com/users/horike37/orgs","repos_url":"https://api.github.com/users/horike37/repos","events_url":"https://api.github.com/users/horike37/events{/privacy}","received_events_url":"https://api.github.com/users/horike37/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-29T20:50:55Z","updated_at":"2016-09-01T10:55:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/serverless/serverless/pulls/1978","html_url":"https://github.com/serverless/serverless/pull/1978","diff_url":"https://github.com/serverless/serverless/pull/1978.diff","patch_url":"https://github.com/serverless/serverless/pull/1978.patch"},"body":"<!--\r\n1. Please check out and follow our Contributing Guidelines: https://github.com/serverless/serverless/blob/master/CONTRIBUTING.md\r\n2. Fill out the whole template so we have a good overview on the issue\r\n3. Please follow the template, otherwise we'll have to ask you to update it\r\n-->\r\n\r\n***Implementing Issue:*** #1271\r\n\r\n## What did you implement:\r\nI implemented #1271\r\n<!--\r\nBriefly describe the feature\r\n-->\r\n\r\n## How did you implement it:\r\nI implemented that the PluginManager can check against a regular expression.\r\nIf the check fail, the errorMessage is displayed.\r\n```\r\nfoo: {\r\n  options: {\r\n    bar: {\r\n      customValidation: {\r\n        regularExpression: /^[0-9]+$/,\r\n        errorMessage: 'Custom Error Message',\r\n      },\r\n    },\r\n  },\r\n}\r\n```\r\n<!--\r\nIf this is a nontrivial change please briefly describe your implementation.\r\n-->\r\n\r\n## How can we verify it:\r\nPlease set customValidation option in a plugin.\r\n\r\n```\r\noptions: {\r\n  stage: {\r\n    usage: 'Stage of the service',\r\n    shortcut: 's',\r\n  },\r\n  region: {\r\n    usage: 'Region of the service',\r\n    shortcut: 'r',\r\n    customValidation: {\r\n      regularExpression: /^[0-9]+$/,\r\n      errorMessage: 'Custom Error Message',\r\n    },\r\n  },\r\n}\r\n```\r\n\r\nIf the check fail, the errorMessage is displayed.\r\n<img width=\"832\" alt=\"2016-08-30 5 45 08\" src=\"https://cloud.githubusercontent.com/assets/1301012/18066833/10c72c62-6e75-11e6-89e7-b435ff829a3e.png\">\r\n\r\n<!--\r\nAdd any applicable config, commands, screenshots or other resources\r\nto make it easy for us to verify this works, e.g. an example serverless.yml\r\nor AWS CLI commands to trigger something.\r\n-->\r\n\r\n\r\n## Todos:\r\n\r\n- [x] Write tests\r\n- [x] Fix linting errors\r\n- [x] Provide verification config/commands/resources\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/serverless/serverless/issues/comments/244045044","html_url":"https://github.com/serverless/serverless/pull/1978#issuecomment-244045044","issue_url":"https://api.github.com/repos/serverless/serverless/issues/1978","id":244045044,"user":{"login":"flomotlik","id":132653,"avatar_url":"https://avatars.githubusercontent.com/u/132653?v=3","gravatar_id":"","url":"https://api.github.com/users/flomotlik","html_url":"https://github.com/flomotlik","followers_url":"https://api.github.com/users/flomotlik/followers","following_url":"https://api.github.com/users/flomotlik/following{/other_user}","gists_url":"https://api.github.com/users/flomotlik/gists{/gist_id}","starred_url":"https://api.github.com/users/flomotlik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flomotlik/subscriptions","organizations_url":"https://api.github.com/users/flomotlik/orgs","repos_url":"https://api.github.com/users/flomotlik/repos","events_url":"https://api.github.com/users/flomotlik/events{/privacy}","received_events_url":"https://api.github.com/users/flomotlik/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T10:55:48Z","updated_at":"2016-09-01T10:55:48Z","body":"Could you also add a test that succeeds with a custom Regex validation? At the moment we only know that it will fail, but there is no test case with a custom regex where the regex matches and it succeeds"}}
{"actor":{"display_login":"flomotlik"}}