Test case
1 generated file · +7 −7test/inputs/schema/minmaxlength.schema
Mschema-rubydefault / TopLevel.rb+7 −7
| @@ -22,7 +22,7 @@ end | ||
| 22 | 22 | |
| 23 | 23 | class InUnion < Dry::Struct |
| 24 | 24 | attribute :double, Types::Double.optional |
| 25 | - attribute :string, Types::String.optional | |
| 25 | + attribute :string, Types::String.constrained(min_size: 3, max_size: 5).optional | |
| 26 | 26 | |
| 27 | 27 | def self.from_dynamic!(d) |
| 28 | 28 | if schema.key(:double).type.right.valid? d |
| @@ -52,14 +52,14 @@ class InUnion < Dry::Struct | ||
| 52 | 52 | end |
| 53 | 53 | |
| 54 | 54 | class TopLevel < Dry::Struct |
| 55 | - attribute :intersection, Types::String | |
| 55 | + attribute :intersection, Types::String.constrained(min_size: 4, max_size: 5) | |
| 56 | 56 | attribute :in_union, Types.Instance(InUnion) |
| 57 | - attribute :maxlength, Types::String | |
| 58 | - attribute :minlength, Types::String | |
| 59 | - attribute :min_max_intersection, Types::String | |
| 60 | - attribute :minmaxlength, Types::String | |
| 57 | + attribute :maxlength, Types::String.constrained(max_size: 5) | |
| 58 | + attribute :minlength, Types::String.constrained(min_size: 3) | |
| 59 | + attribute :min_max_intersection, Types::String.constrained(min_size: 3, max_size: 5) | |
| 60 | + attribute :minmaxlength, Types::String.constrained(min_size: 3, max_size: 5) | |
| 61 | 61 | attribute :min_max_union, Types::String |
| 62 | - attribute :union, Types::String | |
| 62 | + attribute :union, Types::String.constrained(min_size: 3, max_size: 6) | |
| 63 | 63 | |
| 64 | 64 | def self.from_dynamic!(d) |
| 65 | 65 | d = Types::Hash[d] |
Test case
1 generated file · +2 −2test/inputs/schema/optional-const-ref.schema
Mschema-rubydefault / TopLevel.rb+2 −2
| @@ -52,10 +52,10 @@ end | ||
| 52 | 52 | class TopLevel < Dry::Struct |
| 53 | 53 | attribute :coordinates, Types.Array(Coordinate).optional |
| 54 | 54 | attribute :count, Types::Integer.optional |
| 55 | - attribute :label, Types::String.optional | |
| 55 | + attribute :label, Types::String.constrained(min_size: 2, max_size: 16).optional | |
| 56 | 56 | attribute :required_coordinates, Types.Array(Coordinate) |
| 57 | 57 | attribute :required_count, Types::Integer |
| 58 | - attribute :required_label, Types::String | |
| 58 | + attribute :required_label, Types::String.constrained(min_size: 2, max_size: 16) | |
| 59 | 59 | attribute :weight, Types::Double.optional |
| 60 | 60 | |
| 61 | 61 | def self.from_dynamic!(d) |
Test case
1 generated file · +1 −1test/inputs/schema/optional-constraints.schema
Mschema-rubydefault / TopLevel.rb+1 −1
| @@ -25,7 +25,7 @@ class TopLevel < Dry::Struct | ||
| 25 | 25 | attribute :opt_double, Types::Double.optional |
| 26 | 26 | attribute :opt_int, Types::Integer.optional |
| 27 | 27 | attribute :opt_pattern, Types::String.optional |
| 28 | - attribute :opt_string, Types::String.optional | |
| 28 | + attribute :opt_string, Types::String.constrained(min_size: 3, max_size: 10).optional | |
| 29 | 29 | attribute :req_zero_min, Types::Integer |
| 30 | 30 | |
| 31 | 31 | def self.from_dynamic!(d) |
Test case
1 generated file · +2 −2test/inputs/schema/renaming-bug.schema
Mschema-rubydefault / TopLevel.rb+2 −2
| @@ -212,7 +212,7 @@ end | ||
| 212 | 212 | |
| 213 | 213 | class Berry < Dry::Struct |
| 214 | 214 | attribute :color, Color.optional |
| 215 | - attribute :berry_name, Types::String.optional | |
| 215 | + attribute :berry_name, Types::String.constrained(min_size: 1).optional | |
| 216 | 216 | attribute :shapes, Types.Array(Shape).optional |
| 217 | 217 | |
| 218 | 218 | def self.from_dynamic!(d) |
| @@ -379,7 +379,7 @@ end | ||
| 379 | 379 | |
| 380 | 380 | class Vehicle < Dry::Struct |
| 381 | 381 | attribute :brand, Types::String.optional |
| 382 | - attribute :id, Types::String.optional | |
| 382 | + attribute :id, Types::String.constrained(min_size: 1).optional | |
| 383 | 383 | attribute :speed, Speed.optional |
| 384 | 384 | attribute :sub_module, Types::Bool.optional |
| 385 | 385 | attribute :vehicle_type, VehicleType.optional |
Test case
1 generated file · +1 −1test/inputs/schema/schema-constraints.schema
Mschema-rubydefault / TopLevel.rb+1 −1
| @@ -21,7 +21,7 @@ module Types | ||
| 21 | 21 | end |
| 22 | 22 | |
| 23 | 23 | class TopLevel < Dry::Struct |
| 24 | - attribute :min_max_length, Types::String | |
| 24 | + attribute :min_max_length, Types::String.constrained(min_size: 5, max_size: 5) | |
| 25 | 25 | attribute :percent, Types::Double |
| 26 | 26 | |
| 27 | 27 | def self.from_dynamic!(d) |
No generated files match these filters.