standardapi 7.1.2 → 7.1.3

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: cb9fe722c9847c5c2aa696b36fdbebbc4783f78d92036683b03cde0929f7b78a
4
- data.tar.gz: 6723597440138d500614b84f34106279778addc18bd40419d854b0e7bbb628cc
3
+ metadata.gz: 692542999da28b20821233c6649dcc8e4b66bdf76183b44ab665ff2452cd0cfd
4
+ data.tar.gz: 92cf5184a56a2695f34478bd29895d5aa6ba01181548eb77a990da5b8e62f28b
5
5
  SHA512:
6
- metadata.gz: 8aa742b8fda2329a7c17b314ac2b40c8ae46b139fa482516166e7c19a96e851c8438062a89b9de114a5425eaa429c69327faf1fb01b5b4e7e78f1415646a5669
7
- data.tar.gz: 8f17ce9c37b5948c726e8cc13166acf8f5be4b7b63103d8c7eb55f308abfe65a6688000ac8b58a062bd30d8d385225a17ae9e8e80d34e8c757634084cab4776a
6
+ metadata.gz: 99356387601124215ce2d86926cdb98d04b38c3141d4a6affa7ba6464c2f0d6342fe506ce34859a284499e626eb1cc0c2573364cf13cb4d8d9216210b24a8120
7
+ data.tar.gz: b54933f7376b9f672f2a37ef8c2fd21893c37650907b906b6ccfdc2f489a0b37a6bc3fa639e3e374d023a8645557c33b408a0024763d2ae8f24a9bc822154975
@@ -1,3 +1,3 @@
1
1
  module StandardAPI
2
- VERSION = '7.1.2'
2
+ VERSION = '7.1.3'
3
3
  end
@@ -77,7 +77,7 @@ else
77
77
  end)
78
78
 
79
79
  visitor = StandardAPI::Visitors::Validator.new
80
- validations = model.validators.select { |v| v.attributes.include?(column.name.to_sym) }.map { |v| visitor.accept(v, {}) }
80
+ validations = model.validators.select { |v| v.attributes.include?(column.name.to_sym) }.map { |v| visitor.accept(v, {}) }.compact
81
81
  json.set! 'validations', validations
82
82
  end
83
83
  end
@@ -87,7 +87,7 @@ else
87
87
  end)
88
88
 
89
89
  visitor = StandardAPI::Visitors::Validator.new
90
- validations = model.validators.select { |v| v.attributes.include?(column.name.to_sym) }.map { |v| visitor.accept(v, {}) }
90
+ validations = model.validators.select { |v| v.attributes.include?(column.name.to_sym) }.map { |v| visitor.accept(v, {}) }.compact
91
91
  json.set! 'validations', validations
92
92
  end
93
93
  end
@@ -47,12 +47,25 @@ module StandardAPI
47
47
  visit_validator(:with, o.options)
48
48
  end
49
49
 
50
+ def visit_ActiveModel_Validations_FormatValidator(o, col)
51
+ visit_validator(:format, o.options)
52
+ end
53
+
50
54
  private
51
55
 
52
56
  def visit_validator(name, options)
53
57
  { name => options.empty? ? true : options.as_json }
54
58
  end
55
59
 
60
+ def visit(object, collector = nil)
61
+ dispatch_method = dispatch[object.class]
62
+ if collector
63
+ send dispatch_method, object, collector
64
+ else
65
+ send dispatch_method, object
66
+ end
67
+ rescue NoMethodError => e
68
+ end
56
69
 
57
70
  end
58
71
 
@@ -164,6 +164,10 @@ class PropertiesControllerTest < ActionDispatch::IntegrationTest
164
164
  assert_equal true, schema['models']['Account']['attributes']['id']['readonly']
165
165
  assert_equal false, schema['models']['Account']['attributes']['name']['readonly']
166
166
 
167
+ assert_equal [
168
+ {"format"=>{"allow_nil"=>true, "with"=>"(?-mix:.+@.+)"}}
169
+ ], schema['models']['Account']['attributes']['email']['validations']
170
+
167
171
  assert_equal [
168
172
  { "presence" => true }
169
173
  ], schema['models']['Property']['attributes']['name']['validations']
@@ -1,6 +1,7 @@
1
1
  # = Models
2
2
 
3
3
  class Account < ActiveRecord::Base
4
+ validates :email, format: /.+@.+/, allow_nil: true
4
5
  has_many :photos, -> { order(:created_at) }
5
6
  belongs_to :property
6
7
  belongs_to :subject, polymorphic: true
@@ -113,6 +114,7 @@ class CreateModelTables < ActiveRecord::Migration[6.0]
113
114
 
114
115
  create_table "accounts", force: :cascade do |t|
115
116
  t.string 'name', limit: 255
117
+ t.string 'email', limit: 255
116
118
  t.integer 'property_id'
117
119
  t.integer "subject_id"
118
120
  t.string "subject_type"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standardapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.2
4
+ version: 7.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-15 00:00:00.000000000 Z
11
+ date: 2024-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails