dry-types icon indicating copy to clipboard operation
dry-types copied to clipboard

Add better support for ranges

Open budu opened this issue 3 years ago • 0 comments

Hi, I'd like to use dry-schema for an application dealing with lots of ranges. The current support for ranges in dry-types doesn't handle checks for its member values, which is the issue this PR is trying to solve.

I've based my work on the current implementation for arrays and tried to include everything from test to documentation. Coding was pretty straightforward considering I don't have much experience with dry libraries.

Here's an example of using this feature:

IntegerRange = Types::Range.of(Types::Coercible::Integer)
IntegerRange[1.0..2.0] # 1..2

Things to improve

  • support for exclude_end option
  • range? predicate in dry-logic

budu avatar Sep 12 '22 02:09 budu