# add meta info to dry-validation schema

**URL:** <https://discourse.dry-rb.org/t/add-meta-info-to-dry-validation-schema/1674>\
**Category:** dry-validation\
**Created:** [May 17, 2023, 1:29am UTC](https://discourse.dry-rb.org/t/add-meta-info-to-dry-validation-schema/1674 "2023-05-17T01:29:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rash\_pro](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/rash_pro/32/876_2.png) [@rash\_pro](https://discourse.dry-rb.org/u/rash_pro)\
**Post date:** [May 17, 2023, 1:29am UTC](https://discourse.dry-rb.org/t/add-meta-info-to-dry-validation-schema/1674/1 "2023-05-17T01:29:08Z")

</div>

Hello, I’m playing with the idea of defining a dry-validation schema and using it to dynamically generate  
an html form based on it, i’ve reached a point where i it would be nice to pass some additional metadata to the form, I’ve searched and saw the Dry::Types::Meta and that seems to fulfill my needs but it’s a bit verbose having to pass filled(Dry::Type[“integer”]) instead of filled(:integer), is there an api to pass the meta directly from the dry-validation schema or would i need to roll my own?

thanks in advance, and thank you for such an amazing proyect

---

<div class="post-metadata">

**Author:** ![alassek](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/alassek/32/314_2.png) [@alassek](https://discourse.dry-rb.org/u/alassek)\
**Post date:** [May 17, 2023, 4:32pm UTC](https://discourse.dry-rb.org/t/add-meta-info-to-dry-validation-schema/1674/2 "2023-05-17T16:32:25Z")

</div>

I’m not aware of any interface for metadata in dry-schema, I have only ever seen that applied to concrete types directly.

It probably wouldn’t be very difficult to add a new Macro for metadata, but you’re on your own there.

If you’re doing anything remotely complicated, you’ll almost certainly want custom types for things. My approach is to define a Types module and alias it to T for brevity

```ruby
# since this is for HTML forms, you'll probably want params
Types = Dry::Types(default: :params)

module Types
  # custom types defined here
end

T = Types

```

Then I will reference it in schemas like `T::Integer`

```ruby
required(:field).value(T::Integer.meta(foo: "bar"))

```

---

<div class="post-metadata">

**Author:** ![rash\_pro](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/rash_pro/32/876_2.png) [@rash\_pro](https://discourse.dry-rb.org/u/rash_pro)\
**Post date:** [May 17, 2023, 7:03pm UTC](https://discourse.dry-rb.org/t/add-meta-info-to-dry-validation-schema/1674/3 "2023-05-17T19:03:48Z")

</div>

> [@alassek](#):
>
> If you’re doing anything remotely complicated, you’ll almost certainly want custom types for things. My approach is to define a Types module and alias it to T for brevity

Thanks for the reply, the T shortcut looks pretty good will definitely use it, and look at adding a macro for the metadata. 🙂
