Skip to content

Instantly share code, notes, and snippets.

@iamveen
Last active June 24, 2019 21:03
Show Gist options
  • Save iamveen/325c887c4a747ad37085667186421ac0 to your computer and use it in GitHub Desktop.
Save iamveen/325c887c4a747ad37085667186421ac0 to your computer and use it in GitHub Desktop.
dry-rb cheatsheet

Dry Schema

Types

str?            # equivalent to type?(String)
int?            # equivalent to type?(Integer)
float?          # equivalent to type?(Float)
decimal?        # equivalent to type?(BigDecimal)
bool?           # equivalent to type?(Boolean)
date?           # equivalent to type?(Date)
time?           # equivalent to type?(Time)
date_time?      # equivalent to type?(DateTime)
array?          # equivalent to type?(Array)
hash?           # equivalent to type?(Hash)

Number, String, Collection

empty?          # Checks that either the array, string, or hash is empty.
filled?         # Checks that either the value is non-nil and, in the case of a String, Hash, or Array, non-empty.
gt?             # Checks that the value is greater than the given value.
gteq?           # Checks that the value is greater than or equal to the given value.
lt?             # Checks that the value is less than the given value.
lteq?           # Checks that the value is less than or equal to the given value.
max_size?       # Check that an array’s size (or a string’s length) is less than or equal to the given value.
min_size?       # Checks that an array’s size (or a string’s length) is greater than or equal to the given value.
size?(int)      # Checks that an array’s size (or a string’s length) is equal to the given value.
size?(range)    # Checks that an array’s size (or a string’s length) is within a range of values.
format?         # Checks that a string matches a given regular expression.
included_in?    # Checks that a value is included in a given array.
excluded_from?  # Checks that a value is excluded from a given array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment