You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a custom type and using with the array rule, it appears that the validations applied by the type are not applied always by the rule. See the example below, and note that the last test is failing when it shouldn't:
RSpec.describeTypes::StringOrHashdoit'works with a valid hash input'doexpect{described_class[{bar: 'baz'}]}.not_toraise_errorendit'works with a valid string input'doexpect{described_class['foo']}.not_toraise_errorendit'fails with an invalid string input'doexpect{described_class['bar']}.toraise_errorendit'fails with a hash with invalid values'doexpect{described_class[{bar: 'quz'}]}.toraise_errorendit'fails with a hash with invalid keys'doexpect{described_class[{quz: 'baz'}]}.toraise_errorendend
The first test passes, the second fails:
RSpec.describeTestContractdosubject{described_class.new.call(params)}context'when passing a valid array'dolet(:params){{test: ['foo',{bar: 'baz'}]}}it{is_expected.tobe_success}end# THIS TEST FAILScontext'when passing an invalid array'dolet(:params){{test: ['foo',{bar: 'qux'}]}}it{is_expected.tobe_failure}endend
Expected behavior
It is expected that the validation fails when the input value is not of the described value.
My environment
Affects my production application: YES
Ruby version: 2.7.5
OS: MacOS Monterrey 12.0.1 (Apple chip)
The text was updated successfully, but these errors were encountered:
This is a duplicate of dry-rb/dry-validation#713
Describe the bug
When creating a custom type and using with the
array
rule, it appears that the validations applied by the type are not applied always by the rule. See the example below, and note that the last test is failing when it shouldn't:To Reproduce
These tests all pass as expected:
The first test passes, the second fails:
Expected behavior
It is expected that the validation fails when the input value is not of the described value.
My environment
The text was updated successfully, but these errors were encountered: