easy_talk 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa39fe0359df9334a186807b3e67679b752806db59eb9b03829ec875c6382818
4
- data.tar.gz: 150814754a0604fc0149bf042c73d798fe042935ffde11b52c2254ac765c05e8
3
+ metadata.gz: 4956da04f8ac9e83e12f4ad476e4e340f44b7b9d6c2fb021bbe1afc0b93ef0f2
4
+ data.tar.gz: 2c64f966e265f5815db6e00bd38412dbef4262344feb270b75e269e71b81df55
5
5
  SHA512:
6
- metadata.gz: ea9d64a999260983afac690850ae5095b4e2d00583feb1a6dd4baa0a0cb377a82566dae1245e1b767e5ff79549f28e60209b43fa3d765a8b51c46ee6969425bd
7
- data.tar.gz: 20e3bea29ad389126937924f431f8729be43b172f8f868ae5fc0189d729e1d19642a9fa0e74a34322e1acafd2b74c6b2fad20bb8f081c7ea504364a2daaf3d99
6
+ metadata.gz: 4c1b91b2c67cd7d3b458f83bf1da9e483ba5ec67ff346242239e39b9fc88d7ce6eab78eef5ba942db85a8df78431ba1886111e1927c5edf2fdb35f70b22ecd8f
7
+ data.tar.gz: 915aa38e52e371d38eaa2a9175d4a0e92a34e999963dae8f9654a6117fb66ed514926063a49fcd6564ecba192a01e7310f6707d670be5245a49993264e3be5a9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## [1.0.1] - 2024-09-01
2
+ - Fixed that property with custom type does not ignore the constraints hash https://github.com/sergiobayona/easy_talk/issues/17
1
3
  ## [1.0.0] - 2024-06-01
2
4
  - Use `Hash` instead of `:object` for inline object schema definition.
3
5
  example:
@@ -76,15 +76,15 @@ module EasyTalk
76
76
  #
77
77
  # @return [Object] The built property.
78
78
  def build
79
- # return type.respond_to?(:schema) ? type.schema : 'object' unless builder
80
-
81
- # args = builder.collection_type? ? [name, type, constraints] : [name, constraints]
82
- # builder.new(*args).build
83
79
  if builder
84
80
  args = builder.collection_type? ? [name, type, constraints] : [name, constraints]
85
81
  builder.new(*args).build
82
+ elsif type.respond_to?(:schema)
83
+ # merge the top-level constraints from *this* property
84
+ # e.g. :title, :description, :default, etc
85
+ type.schema.merge!(constraints)
86
86
  else
87
- type.respond_to?(:schema) ? type.schema : 'object'
87
+ 'object'
88
88
  end
89
89
  end
90
90
 
@@ -4,13 +4,13 @@ require_relative 'keywords'
4
4
 
5
5
  module EasyTalk
6
6
  class InvalidPropertyNameError < StandardError; end
7
+
7
8
  #
8
9
  #= EasyTalk \SchemaDefinition
9
10
  # SchemaDefinition provides the methods for defining a schema within the define_schema block.
10
11
  # The @schema is a hash that contains the unvalidated schema definition for the model.
11
12
  # A SchemaDefinition instanace is the passed to the Builder.build_schema method to validate and compile the schema.
12
13
  class SchemaDefinition
13
-
14
14
  extend T::Sig
15
15
  extend T::AnyOf
16
16
  extend T::OneOf
@@ -56,9 +56,10 @@ module EasyTalk
56
56
  end
57
57
 
58
58
  def validate_property_name(name)
59
- unless name.to_s.match?(/^[A-Za-z_][A-Za-z0-9_]*$/)
60
- raise InvalidPropertyNameError, "Invalid property name '#{name}'. Must start with letter/underscore and contain only letters, numbers, underscores"
61
- end
59
+ return if name.to_s.match?(/^[A-Za-z_][A-Za-z0-9_]*$/)
60
+
61
+ raise InvalidPropertyNameError,
62
+ "Invalid property name '#{name}'. Must start with letter/underscore and contain only letters, numbers, underscores"
62
63
  end
63
64
 
64
65
  def optional?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EasyTalk
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_talk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Bayona