# Inconsistent behavior when inheriting with .Schema, .Form, and .JSON

**URL:** <https://discourse.dry-rb.org/t/inconsistent-behavior-when-inheriting-with-schema-form-and-json/336>\
**Category:** Uncategorized\
**Created:** [August 24, 2017, 6:54pm UTC](https://discourse.dry-rb.org/t/inconsistent-behavior-when-inheriting-with-schema-form-and-json/336 "2017-08-24T18:54:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![binarypaladin](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/binarypaladin/32/127_2.png) [@binarypaladin](https://discourse.dry-rb.org/u/binarypaladin)\
**Post date:** [August 24, 2017, 6:54pm UTC](https://discourse.dry-rb.org/t/inconsistent-behavior-when-inheriting-with-schema-form-and-json/336/1 "2017-08-24T18:54:46Z")

</div>

I was originally going to file an issue on Github, but I don’t know if this is inconsistent behavior or intended.

Consider this basic schema:

```auto
schema = Dry::Validation.Schema { required(:name).filled(:str?) }

```

If I want to extend this schema, I can do something like this:

```auto
new_schema = Dry::Validation.Schema(schema) { required(:age).filled(:int?) }

```

However, if I try to do the same using .Form or .JSON, there’s a problem:

```auto
form = Dry::Validation.Form(schema) { required(:age).filled(:int?) }

=> TypeError: superclass must be a Class (#<Class:0x007f82969fc818> given)
from /gems/dry-validation-0.11.0/lib/dry/validation.rb:28:in `initialize'

```

This works fine:

```auto
form = Dry::Validation.Form(schema.class) { required(:age).filled(:int?) }

```

.Schema handles this situation with the following code:

```auto
schema_class = Class.new(base.is_a?(Schema) ? base.class : base)

```

However, .Form and .JSON assume they’re dealing with a class so they fail before calling .Schema. To me, this behavior was unexpected and required a code dive to understand what was going on. With that said, I can’t honestly say if it’s a bug.

If this behavior is considered a bug, I can put together a PR pretty quickly. (The guidelines say “A Pull Request will only be accepted if it addresses a specific issue that was reported previously” and since I can’t tell if this is even a bug I dunno if it’s an issue, lol. Maybe I’m being way too pedantic.)
