adf_builder 1.3.0 → 1.4.0

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: d362b1ad0b8a252bd6e941a5c1c2572b098d1b0fb98da0eed415fa3074297fff
4
- data.tar.gz: 8319bcc2fd7289ac3e0dfd46be7deb46166b1b2b1cbea247ad1b5eeac2f86b87
3
+ metadata.gz: 440064d9196befba72c7a471b56db7a5b31f28b0521b7d2fbd0588e09fe9d0d9
4
+ data.tar.gz: fd917e6692abc141a2d1aa4e8c84c47b3ce7ce2ea3061cf6006364d8d51dbf9a
5
5
  SHA512:
6
- metadata.gz: f49bb434697231563e420d4da2123b38370b61ac8b83ae5e6e6d7ad3517c6308acdd7a4db70e7a3866f5c578c4f2bd012a7830d94a69dc0ca8aacd6c941f9dbc
7
- data.tar.gz: 5441957e0585459da711b7943e8e5d0eca3b4d596c54159178a71656c6a532c185dcf5395765eae75dbe46c3a6df5d8c80eb02a8e9101f1cc25b09698c32549f
6
+ metadata.gz: a1f11e9074f3a54daa855ac0a1ba732cc7924552ac717efda4f62d2db53aee311d960221eb226a163853a3f7aac52c05feabcdb4b6dc2af554288129123b42ab
7
+ data.tar.gz: 9a0f287c7182b673ce9230d01f609f0644e5e4094117a794aab5fc5f53a96b86f8115dd89357b0f07e7ccf9ff4e8e965128e2fe06aa6c9a3d6a1f6da9b906f7a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [1.4.0] - 2026-01-19
2
+ - **Vendor & Customer Validation Improvements**:
3
+ - `Vendor`: Now requires `vendorname` and `contact`.
4
+ - `Customer`: Now requires `contact`.
5
+ - `Contact`: Refactored to use declarative `validates_presence_of :name` (previously manual check).
6
+ - Added comprehensive specs for new presence validations.
7
+
8
+ ## [1.3.1] - 2026-01-19
9
+ - **Validation Refinement**: `Address` now strictly enforces 1 to 5 `street` lines.
10
+
1
11
  ## [1.3.0] - 2026-01-19
2
12
  - **Customer & Contact Validations**:
3
13
  - `Contact`: Requires Name and at least one Phone or Email.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adf_builder (1.2.2)
4
+ adf_builder (1.3.1)
5
5
  ox (~> 2.14)
6
6
 
7
7
  GEM
@@ -7,6 +7,8 @@ module AdfBuilder
7
7
  super
8
8
  @tag_name = :customer
9
9
  end
10
+ validates_presence_of :contact
11
+
10
12
 
11
13
  def contact(&block)
12
14
  remove_children(:contact)
@@ -66,10 +66,16 @@ module AdfBuilder
66
66
  @attributes[:type] = type if type
67
67
  end
68
68
 
69
- def street(value, line: nil)
70
- # Line validation 1-5
71
- raise AdfBuilder::Error, "Street line must be 1-5" if line && !line.to_s.match?(/^[1-5]$/)
69
+ def validate!
70
+ super
71
+ streets = @children.select { |c| c.tag_name == :street }
72
+ raise AdfBuilder::Error, "Address must have at least one street line" if streets.empty?
73
+ return unless streets.size > 5
72
74
 
75
+ raise AdfBuilder::Error, "Address can have at most 5 street lines"
76
+ end
77
+
78
+ def street(value, line: nil)
73
79
  node = GenericNode.new(:street, { line: line }.compact, value)
74
80
  add_child(node)
75
81
  end
@@ -88,6 +94,7 @@ module AdfBuilder
88
94
 
89
95
  class Contact < Node
90
96
  validates_inclusion_of :primarycontact, in: [0, 1, "0", "1"]
97
+ validates_presence_of :name
91
98
 
92
99
  def initialize(primary_contact: nil)
93
100
  super()
@@ -97,9 +104,6 @@ module AdfBuilder
97
104
 
98
105
  def validate!
99
106
  super
100
- # Custom Validation: Name is required
101
- raise AdfBuilder::Error, "Contact must have a Name" unless @children.any? { |c| c.tag_name == :name }
102
-
103
107
  # Custom Validation: At least one Phone OR Email
104
108
  return if @children.any? { |c| %i[phone email].include?(c.tag_name) }
105
109
 
@@ -7,6 +7,7 @@ module AdfBuilder
7
7
  super
8
8
  @tag_name = :vendor
9
9
  end
10
+ validates_presence_of :vendorname, :contact
10
11
 
11
12
  def id(value, sequence: nil, source: nil)
12
13
  add_child(Id.new(value, sequence: sequence, source: source))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdfBuilder
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adf_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - marcus.salinas