{"action":"created","issue":{"url":"https://api.github.com/repos/dry-rb/dry-validation/issues/99","repository_url":"https://api.github.com/repos/dry-rb/dry-validation","labels_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/99/labels{/name}","comments_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/99/comments","events_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/99/events","html_url":"https://github.com/dry-rb/dry-validation/issues/99","id":147124961,"number":99,"title":"Refine DSL","user":{"login":"solnic","id":1066,"avatar_url":"https://avatars.githubusercontent.com/u/1066?v=3","gravatar_id":"","url":"https://api.github.com/users/solnic","html_url":"https://github.com/solnic","followers_url":"https://api.github.com/users/solnic/followers","following_url":"https://api.github.com/users/solnic/following{/other_user}","gists_url":"https://api.github.com/users/solnic/gists{/gist_id}","starred_url":"https://api.github.com/users/solnic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solnic/subscriptions","organizations_url":"https://api.github.com/users/solnic/orgs","repos_url":"https://api.github.com/users/solnic/repos","events_url":"https://api.github.com/users/solnic/events{/privacy}","received_events_url":"https://api.github.com/users/solnic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dry-rb/dry-validation/labels/feature","name":"feature","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2016-04-09T12:17:50Z","updated_at":"2016-04-14T08:55:20Z","closed_at":null,"body":"After discussion in #90 we've ended up with the following proposal:\r\n\r\n``` ruby\r\nkey(:email).required\r\n# becomes\r\nrequired(:email).filled\r\n\r\nrequired(:email).filled\r\n# is a macro for:\r\nrequired(:email).value(:filled?)\r\n\r\n# new `value` method builds rules for a value extracted from the input under specified\r\n# key or attr so:\r\nrequired(:name).value(:filled?, size?: 1..60)\r\n# or shorter:\r\nrequired(:name).filled(size?: 1..60)\r\n\r\n# the `value` method will allow us to be more specific about complex types like\r\n# arrays, ie:\r\nrequired(:tags).value(:filled?).each(:str?)\r\n# which means \"tags must be filled and must be an array and each element must\r\n# be a string\r\n\r\n# we can be more specific, ie:\r\nrequired(:services).value(:filled?, size?: 4).each(:str?)\r\n# which adds a constraint that the services array must have exactly 4 elements\r\n```\r\n\r\nWe can easily deprecate current `required` method and just warn that you should now use `value` instead. Same with `key` and `attr` becoming `required`.\r\n\r\nThis change needs a small tweak though, since we will have `required` instead of `key` or `attr`, we must have a specialized dsl builder object for models, because `required` in case of a model schema, must produce `:attr` rules, not `:key`.\r\n\r\nIf you have any concerns or other ideas, just leave a comment."},"comment":{"url":"https://api.github.com/repos/dry-rb/dry-validation/issues/comments/209835442","html_url":"https://github.com/dry-rb/dry-validation/issues/99#issuecomment-209835442","issue_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/99","id":209835442,"user":{"login":"coop","id":64469,"avatar_url":"https://avatars.githubusercontent.com/u/64469?v=3","gravatar_id":"","url":"https://api.github.com/users/coop","html_url":"https://github.com/coop","followers_url":"https://api.github.com/users/coop/followers","following_url":"https://api.github.com/users/coop/following{/other_user}","gists_url":"https://api.github.com/users/coop/gists{/gist_id}","starred_url":"https://api.github.com/users/coop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coop/subscriptions","organizations_url":"https://api.github.com/users/coop/orgs","repos_url":"https://api.github.com/users/coop/repos","events_url":"https://api.github.com/users/coop/events{/privacy}","received_events_url":"https://api.github.com/users/coop/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T08:55:20Z","updated_at":"2016-04-14T08:55:20Z","body":"I'm going to approach this in 4 steps:\r\n\r\n1. remove `attr` code path (preserved in https://github.com/dry-rb/dry-validation/tree/attr-dsl)\r\n2. `key` gets deprecated in favor of `required`\r\n3. `value` is added\r\n4. `required` gets deprecated in favor of `filled` which sits on top of `value(:filled?)`\r\n\r\nI'm open to any help on this if someone else has been eyeing it off - let me know on the dry-rb gitter channel."}}