• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

notEthan / jsi / 5815158926

pending completion
5815158926

push

github

notEthan
Merge remote-tracking branches 'origin/string_node', 'origin/new_metaschema', 'origin/msn_indicated', 'origin/default_metaschema', 'origin/child_param_default_methods', 'origin/deep_to_frozen', 'origin/ary_subscript_range', 'origin/msn_root_descendent_node', 'origin/msn_default_child', 'origin/schema_module_connect', 'origin/memomap_immutable', 'origin/ruby_names', 'origin/ivar_assign', 'origin/doc' and 'origin/dependabot/github_actions/coverallsapp/github-action-2.2.1' into HEAD

298 of 315 new or added lines in 23 files covered. (94.6%)

1 existing line in 1 file now uncovered.

5207 of 5322 relevant lines covered (97.84%)

320482.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.29
/lib/jsi/schema/validation/array.rb
1
# frozen_string_literal: true
2

3
module JSI
42✔
4
  module Schema::Validation::ArrayLength
42✔
5
    # @private
6
    def internal_validate_maxItems(result_builder)
42✔
7
      if keyword?('maxItems')
661,796✔
8
        value = schema_content['maxItems']
588✔
9
        # The value of this keyword MUST be a non-negative integer.
10
        if internal_integer?(value) && value >= 0
588✔
11
          if result_builder.instance.respond_to?(:to_ary)
588✔
12
            # An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.
13
            result_builder.validate(
504✔
14
              result_builder.instance.to_ary.size <= value,
70✔
15
              'instance array size is greater than `maxItems` value',
16
              keyword: 'maxItems',
17
            )
18
          end
19
        else
20
          result_builder.schema_error('`maxItems` is not a non-negative integer', 'maxItems')
×
21
        end
22
      end
23
    end
24

25
    # @private
26
    def internal_validate_minItems(result_builder)
42✔
27
      if keyword?('minItems')
661,712✔
28
        value = schema_content['minItems']
79,992✔
29
        # The value of this keyword MUST be a non-negative integer.
30
        if internal_integer?(value) && value >= 0
79,992✔
31
          if result_builder.instance.respond_to?(:to_ary)
79,992✔
32
            # An array instance is valid against "minItems" if its size is greater than, or equal to, the value of this keyword.
33
            result_builder.validate(
30,482✔
34
              result_builder.instance.to_ary.size >= value,
4,358✔
35
              'instance array size is less than `minItems` value',
36
              keyword: 'minItems',
37
            )
38
          end
39
        else
40
          result_builder.schema_error('`minItems` is not a non-negative integer', 'minItems')
×
41
        end
42
      end
43
    end
44
  end
45
  module Schema::Validation::UniqueItems
42✔
46
    # @private
47
    def internal_validate_uniqueItems(result_builder)
42✔
48
      if keyword?('uniqueItems')
661,586✔
49
        value = schema_content['uniqueItems']
53,416✔
50
        # The value of this keyword MUST be a boolean.
51
        if value == false
53,416✔
52
          # If this keyword has boolean value false, the instance validates successfully.
53
          # (noop)
54
        elsif value == true
50,218✔
55
          if result_builder.instance.respond_to?(:to_ary)
50,224✔
56
            # If it has boolean value true, the instance validates successfully if all of its elements are unique.
57
            result_builder.validate(
7,518✔
58
              result_builder.instance.uniq.size == result_builder.instance.size,
1,068✔
59
              "instance array items' uniqueness does not match `uniqueItems` value",
60
              keyword: 'uniqueItems',
61
            )
62
          end
63
        else
64
          result_builder.schema_error('`uniqueItems` is not a boolean', 'uniqueItems')
×
65
        end
66
      end
67
    end
68
  end
69
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc