{"action":"created","issue":{"url":"https://api.github.com/repos/dry-rb/dry-validation/issues/251","repository_url":"https://api.github.com/repos/dry-rb/dry-validation","labels_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/251/labels{/name}","comments_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/251/comments","events_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/251/events","html_url":"https://github.com/dry-rb/dry-validation/issues/251","id":175253990,"number":251,"title":"make sure that a key rule is added as a minimum when using 'required' without additional restrictions","user":{"login":"pvmeerbe","id":701732,"avatar_url":"https://avatars.githubusercontent.com/u/701732?v=3","gravatar_id":"","url":"https://api.github.com/users/pvmeerbe","html_url":"https://github.com/pvmeerbe","followers_url":"https://api.github.com/users/pvmeerbe/followers","following_url":"https://api.github.com/users/pvmeerbe/following{/other_user}","gists_url":"https://api.github.com/users/pvmeerbe/gists{/gist_id}","starred_url":"https://api.github.com/users/pvmeerbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvmeerbe/subscriptions","organizations_url":"https://api.github.com/users/pvmeerbe/orgs","repos_url":"https://api.github.com/users/pvmeerbe/repos","events_url":"https://api.github.com/users/pvmeerbe/events{/privacy}","received_events_url":"https://api.github.com/users/pvmeerbe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-06T13:57:14Z","updated_at":"2016-09-09T09:55:44Z","closed_at":null,"body":"as discussed on gitter only using  'required(:my_key)'  currently doesn't  create a validation rule in the background. As a result no validation is done, which is not what one would expect. \r\n\r\nSee http://pastebin.com/1KrDRzSB\r\n\r\n    schema = Dry::Validation.Schema do\r\n       required(:email)\r\n    end\r\n\r\n    schema.rules\r\n     #  => {}\r\n\r\nSuggestion from Fran  Worley  on gitter : \r\n\r\n       @solnic we probably should make sure that a key rule is added as a minimum if you call required, I can see it confusing people especially as you can't use the key? predicate independently."},"comment":{"url":"https://api.github.com/repos/dry-rb/dry-validation/issues/comments/245871235","html_url":"https://github.com/dry-rb/dry-validation/issues/251#issuecomment-245871235","issue_url":"https://api.github.com/repos/dry-rb/dry-validation/issues/251","id":245871235,"user":{"login":"pvmeerbe","id":701732,"avatar_url":"https://avatars.githubusercontent.com/u/701732?v=3","gravatar_id":"","url":"https://api.github.com/users/pvmeerbe","html_url":"https://github.com/pvmeerbe","followers_url":"https://api.github.com/users/pvmeerbe/followers","following_url":"https://api.github.com/users/pvmeerbe/following{/other_user}","gists_url":"https://api.github.com/users/pvmeerbe/gists{/gist_id}","starred_url":"https://api.github.com/users/pvmeerbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvmeerbe/subscriptions","organizations_url":"https://api.github.com/users/pvmeerbe/orgs","repos_url":"https://api.github.com/users/pvmeerbe/repos","events_url":"https://api.github.com/users/pvmeerbe/events{/privacy}","received_events_url":"https://api.github.com/users/pvmeerbe/received_events","type":"User","site_admin":false},"created_at":"2016-09-09T09:55:44Z","updated_at":"2016-09-09T09:55:44Z","body":"Suggestion for new tests related to this issue is added below. The test \"fails when required option without additional restrictions is not  present\"  will fail due to the current issue.\r\n\r\nAdding the following line\r\n\r\n     add_rule(val) if key_class == Key\r\n\r\nin lib/dry/validation/schema/dsl.rb:108 solves this issue but causes several other tests to fail, so probably not the correct solution...\r\n\r\n   \r\n\r\n    RSpec.describe Dry::Validation::Schema do\r\n      describe 'defining schema with required keys' do\r\n        subject(:schema) do\r\n          Dry::Validation.Schema do\r\n            required(:first_name)\r\n            required(:email) { |email| email.filled? }\r\n          end\r\n        end\r\n    \r\n        describe '#call' do\r\n          it 'success when keys are present with value' do\r\n            expect(schema.(first_name: 'Adriaan', email: 'adriaan@whatever.com')).to be_success\r\n          end\r\n    \r\n          it 'success when required key without additional restrictions is present with nil value' do\r\n            expect(schema.(first_name: nil, email: 'adriaan@whatever.com')).to be_success\r\n          end\r\n    \r\n          it 'success when required key without additional restrictions is present with empty string value' do\r\n            expect(schema.(first_name: '', email: 'adriaan@whatever.com')).to be_success\r\n          end\r\n    \r\n          it 'fails when required key with additional filled? restriction is present with empty string value' do\r\n            expect(schema.(first_name: 'Adriaan', email: '')).to_not be_success\r\n          end\r\n    \r\n          it 'fails when required option without additional restrictions is not  present' do\r\n            expect(schema.(email: 'adriaan@whatever.com')).to_not be_success\r\n          end\r\n    \r\n          it 'fails when required option with additional filled? restrictions is present' do\r\n            expect(schema.(first_name: 'Adriaan')).to_not be_success\r\n          end\r\n    \r\n        end\r\n      end\r\n    end\r\n"}}
{"actor":{"display_login":"pvmeerbe"}}