# Dynamic schema with Configurable's option/param

**URL:** https://discourse.dry-rb.org/t/dynamic-schema-with-configurables-option-param/1800
**Category:** dry-validation
**Created:** [May 9, 2024, 11:00am UTC](https://discourse.dry-rb.org/t/dynamic-schema-with-configurables-option-param/1800 "2024-05-09T11:00:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![freesteph](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/freesteph/32/930_2.png) [@freesteph](https://discourse.dry-rb.org/u/freesteph)
#### Post date: [May 9, 2024, 11:00am UTC](https://discourse.dry-rb.org/t/dynamic-schema-with-configurables-option-param/1800/1 "2024-05-09T11:00:27Z")

</div>

Hello,

I’ve been scratching my head for a couple hours but I can’t figure out how to do this:

```rb
require "dry-validation"

class MySchema < Dry::Validation::Contract
  option :sizes, default: -> { %w[small medium large] }

  params do
    required(:size).value(included_in?: sizes)
  end
end

# MySchema.new(sizes: %w[sm md lg]) 

```

I would like to do this because using Schema’s built-in predicates (`included_in?`) means I don’t have to write a custom rule or message for the value to be included in a dynamic list of things.

This is the correct version:

```rb
require "dry-validation"

class MySchema < Dry::Validation::Contract
  option :sizes, default: -> { %w[small medium large] }

  params do
    required(:size).value(:string)
  end

  rule(:size) do
    key.failure("invalid size") unless sizes.include?(value)
  end
end

```
