saphyr 0.5.0 → 0.6.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: 6b1c26f4af7159d647c18c278b0a57abf7583a8876b401f15f396fb538850f07
4
- data.tar.gz: 29f8fe0a5e93e4d08c6eee677e13a29687f939493d9591e717050986df297089
3
+ metadata.gz: 699e716904911896a384f05b33ea53af443ca41e5981330126a4f0c08be75511
4
+ data.tar.gz: ff47bb4681ce194f3a92d10c4ce407f1a63904608a87de105e9c686bf8c4a64a
5
5
  SHA512:
6
- metadata.gz: 6419db7b64a4a99c50ed40fae4ba2fd8ad098bc92aa3696b5d4a2e43264c6f2dbad98c11841c95944ebf58be4b62f2e3b328b8d17f6f235d8e65cd55019394ea
7
- data.tar.gz: d4c40c6b13270e89551558112ce962cc0c0c8a0ae3ae46529c57a552ab25243b3c19f96e513dc87db509eb22a12b52e10a6438fa7c66d94125f3f602557f2f88
6
+ metadata.gz: a05d896442f9fdede8dd1452ebe61ff03a15ba1c5f58b859fdd9f0fbc34c9a0e153da6fdbeb91fa10a035d66c6b9b026c7c909b8cc1d97bb3e7d90562f9f1a73
7
+ data.tar.gz: 45d6db6210eee29afc46c0ff90eb695b99b833fe3d326bc391dc8a436d4c28b032ddacb1dd9264287883ceb34a37cbd5b9ba6492b0f31638f61acea16c1d40e6
data/CHANGELOG CHANGED
@@ -1,3 +1,18 @@
1
+ -----------------------------------------------------------------
2
+ Version: 0.6.1 - 2025-06-29
3
+
4
+ - Refactor email_field to use assert_string_regexp
5
+ - Make get() variadic to fetch deep fields
6
+ - Add get_safe()
7
+
8
+ -----------------------------------------------------------------
9
+ Version: 0.6.0 - 2025-06-21
10
+
11
+ - Add standard field types
12
+ Email, URI, URL, Base64, ipv4, ipv6, ISO Country, ISO Language
13
+ - Add assert_not_empty
14
+ - Refactor expected_types()
15
+
1
16
  -----------------------------------------------------------------
2
17
  Version: 0.5.0 - 2025-05-21
3
18
 
@@ -6,7 +6,7 @@ module Saphyr
6
6
  value.is_a? TrueClass or value.is_a? FalseClass
7
7
  end
8
8
 
9
- def assert_class klass, value, errors, error_code=Fields::FieldBase::ERR_TYPE
9
+ def assert_class(klass, value, errors, error_code=Fields::FieldBase::ERR_TYPE)
10
10
  klass = [klass] unless klass.is_a? Array
11
11
  test = false
12
12
  klass.each do |k|
@@ -24,7 +24,7 @@ module Saphyr
24
24
  test
25
25
  end
26
26
 
27
- def assert_eq opt_value, value, errors, error_code=Fields::FieldBase::ERR_EQ
27
+ def assert_eq(opt_value, value, errors, error_code=Fields::FieldBase::ERR_EQ)
28
28
  return nil if opt_value.nil?
29
29
  unless value == opt_value
30
30
  errors << {
@@ -39,7 +39,7 @@ module Saphyr
39
39
  true
40
40
  end
41
41
 
42
- def assert_in opt_values, value, errors, error_code=Fields::FieldBase::ERR_IN
42
+ def assert_in(opt_values, value, errors, error_code=Fields::FieldBase::ERR_IN)
43
43
  return nil if opt_values.nil?
44
44
  unless opt_values.include? value
45
45
  errors << {
@@ -53,6 +53,19 @@ module Saphyr
53
53
  end
54
54
  true
55
55
  end
56
+
57
+ def assert_not_empty(value, errors, error_code=Fields::FieldBase::ERR_NOT_EMPTY)
58
+ if value.empty?
59
+ errors << {
60
+ type: err(error_code),
61
+ data: {
62
+ _val: value,
63
+ }
64
+ }
65
+ return false
66
+ end
67
+ true
68
+ end
56
69
  end
57
70
  end
58
71
  end
@@ -5,6 +5,7 @@ module Saphyr
5
5
  # Base
6
6
  ERR_NOT_NULLABLE = 'not-nullable'
7
7
  ERR_BAD_FORMAT = 'bad-format'
8
+ ERR_NOT_EMPTY = 'not-empty'
8
9
  ERR_TYPE = 'type'
9
10
  ERR_IN = 'in'
10
11
  ERR_EQ = 'eq'
data/lib/saphyr/engine.rb CHANGED
@@ -41,7 +41,7 @@ module Saphyr
41
41
  # lookup into the global schemas.
42
42
  # @param name [Symbol] The name of the schema.
43
43
  # @return [Saphyr::Schema]
44
- # @rmaise [Saphyr::Error] if no schema was found.
44
+ # @raise [Saphyr::Error] if no schema was found.
45
45
  def find_schema(name)
46
46
  @validators.each do |validator|
47
47
  schema = validator.find_schema name
@@ -0,0 +1,74 @@
1
+ require 'base64'
2
+
3
+ module Saphyr
4
+ module Fields
5
+
6
+ # The +B64+ field type
7
+ #
8
+ # Allowed options is: +:strict+ (boolean)
9
+ #
10
+ # When in strict mode (:strict == true):
11
+ # - Line breaks are not allowed
12
+ # - Padding must be correct
13
+ #
14
+ # Not in strict mode (:strict == false):
15
+ # - Line breaks are allowed
16
+ # - Padding is not required
17
+ class B64Field < FieldBase
18
+ PREFIX = 'b64'
19
+ EXPECTED_TYPES = String
20
+
21
+ AUTHORIZED_OPTIONS = [:strict] # :strict = true / false
22
+
23
+ FORMAT_REGEXP = /^(?:[A-Za-z0-9+\/]*[\r\n|\n]*)*(?:[=]{1,2})?$/
24
+
25
+ def initialize(opts={})
26
+ if opts[:strict].nil?
27
+ opts[:strict] = true
28
+ else
29
+ unless [true, false].include? opts[:strict]
30
+ raise Saphyr::Error.new "Bad B64 strict option must be a boolean"
31
+ end
32
+ end
33
+ super opts
34
+ end
35
+
36
+ private
37
+
38
+ def do_validate(ctx, name, value, errors)
39
+ return unless assert_not_empty value, errors
40
+ begin
41
+ if @opts[:strict]
42
+ # NOTE: When in strict mode
43
+ # - Line breaks are not allowed
44
+ # - Padding must be correct (length % 4 == 0)
45
+ # In this case, we use Base64.strict_decode64 because it's a way
46
+ # faster than using regexp. An invalid base64 string will raise an error.
47
+ Base64.strict_decode64 value
48
+ else
49
+ # NOTE: When not in strict mode
50
+ # - Line breaks are allowed (like in PEM or EMAIL)
51
+ # - Padding is not required
52
+ # But, we can't use Base64.decode64 because it will not raise an error
53
+ # for a string like this one : 'not-b54**str'.
54
+ # (and obviously it's not a valid base64 format)
55
+ unless FORMAT_REGEXP.match? value
56
+ add_error value, errors
57
+ end
58
+ end
59
+ rescue
60
+ add_error value, errors
61
+ end
62
+ end
63
+
64
+ def add_error(value, errors)
65
+ errors << {
66
+ type: err('invalid'),
67
+ data: {
68
+ _val: value
69
+ }
70
+ }
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,39 @@
1
+ require 'date'
2
+
3
+ module Saphyr
4
+ module Fields
5
+
6
+ # The +DateTime+ field type.
7
+ #
8
+ # Allowed options is: +:format+
9
+ class DateTimeField < FieldBase
10
+ PREFIX = 'datetime'
11
+ EXPECTED_TYPES = String
12
+ AUTHORIZED_OPTIONS = [:format]
13
+
14
+ private
15
+
16
+ def do_validate(ctx, name, value, errors)
17
+ return unless assert_not_empty value, errors
18
+ begin
19
+ if @opts[:format].nil?
20
+ DateTime.parse value
21
+ else
22
+ DateTime.strptime value, @opts[:format]
23
+ end
24
+ rescue
25
+ add_error value, errors
26
+ end
27
+ end
28
+
29
+ def add_error(value, errors)
30
+ errors << {
31
+ type: err('invalid'),
32
+ data: {
33
+ _val: value
34
+ }
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,21 @@
1
+ require 'uri'
2
+
3
+ module Saphyr
4
+ module Fields
5
+
6
+ # The +email+ field type
7
+ #
8
+ # No options are allowed.
9
+ class EmailField < FieldBase
10
+ PREFIX = 'email'
11
+ EXPECTED_TYPES = String
12
+
13
+ private
14
+
15
+ def do_validate(ctx, name, value, errors)
16
+ return unless assert_not_empty value, errors
17
+ assert_string_regexp ::URI::MailTo::EMAIL_REGEXP, value, errors
18
+ end
19
+ end
20
+ end
21
+ end
@@ -61,7 +61,7 @@ module Saphyr
61
61
  NOT_SUP_OR_EQUALS_OPTIONS = []
62
62
 
63
63
  def initialize(opts={})
64
- if self.class::EXPECTED_TYPES.nil?
64
+ if expected_types.nil?
65
65
  raise Saphyr::Error.new "The 'EXPECTED_TYPES' constant must be defined"
66
66
  end
67
67
  if opts.key? :required
@@ -75,12 +75,18 @@ module Saphyr
75
75
  end
76
76
  end
77
77
  if opts.key? :default
78
- unless assert_class self.class::EXPECTED_TYPES, opts[:default], []
78
+ unless assert_class expected_types, opts[:default], []
79
79
  raise Saphyr::Error.new "Option ':default' bad type. Expecting: '#{self.class::EXPECTED_TYPES.to_s}', got: '#{opts[:default].class.name}'"
80
80
  end
81
81
  end
82
82
 
83
- unless authorized_options.size == 0
83
+ if authorized_options.size == 0
84
+ opts.keys.each do |opt|
85
+ unless [:required, :nullable, :default].include? opt
86
+ raise Saphyr::Error.new "Options are not allowed for this field type: '#{opt}'"
87
+ end
88
+ end
89
+ else
84
90
  opts.keys.each do |opt|
85
91
  next if opt == :required or opt == :nullable or opt == :default
86
92
  unless authorized_options.include? opt
@@ -163,6 +169,12 @@ module Saphyr
163
169
 
164
170
  # -----
165
171
 
172
+ # Get the +EXPECTED_TYPES+ options
173
+ # @return [Array]
174
+ def expected_types
175
+ self.class::EXPECTED_TYPES
176
+ end
177
+
166
178
  # Get the +AUTHORIZED_OPTIONS+ options
167
179
  # @return [Array]
168
180
  def authorized_options
@@ -0,0 +1,53 @@
1
+ module Saphyr
2
+ module Fields
3
+
4
+ # The +IP+ field type
5
+ #
6
+ # Allowed options is: +:kind in (:any, :ipv4, :ipv6)+
7
+ #
8
+ # - +:any+ : can be an ipv4 or ipv6 (default)
9
+ # - +:ipv4+ : must be an ipv4
10
+ # - +:ipv6+ : must be an ipv6
11
+ class IpField < FieldBase
12
+ PREFIX = 'ip'
13
+ EXPECTED_TYPES = String
14
+ AUTHORIZED_OPTIONS = [:kind]
15
+
16
+ def initialize(opts={})
17
+ if opts[:kind].nil?
18
+ opts[:kind] = :any
19
+ else
20
+ unless [:any, :ipv4, :ipv6].include? opts[:kind]
21
+ raise Saphyr::Error.new 'Bad IP kind option must be one of :any, :ipv4, :ipv6'
22
+ end
23
+ end
24
+ super opts
25
+ end
26
+
27
+ private
28
+
29
+ def do_validate(ctx, name, value, errors)
30
+ return unless assert_not_empty value, errors
31
+ begin
32
+ ip = IPAddr.new value
33
+ if @opts[:kind] == :ipv4 and not ip.ipv4?
34
+ add_error value, errors
35
+ elsif @opts[:kind] == :ipv6 and not ip.ipv6?
36
+ add_error value, errors
37
+ end
38
+ rescue
39
+ add_error value, errors
40
+ end
41
+ end
42
+
43
+ def add_error(value, errors)
44
+ errors << {
45
+ type: err('invalid'),
46
+ data: {
47
+ _val: value
48
+ }
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,103 @@
1
+ module Saphyr
2
+ module Fields
3
+
4
+ # The +IsoCountry+ field type (ISO-3166-1 alpha 2/3).
5
+ #
6
+ # Allowed options is: +:alpha with possible values: 2 or 3+
7
+ #
8
+ # - +2+ : Mean ISO-3166-1 alpha-2 (defulat)
9
+ # - +3+ : Mean ISO-3166-1 alpha-3
10
+ class IsoCountryField < FieldBase
11
+ PREFIX = 'iso-country'
12
+ EXPECTED_TYPES = String
13
+ AUTHORIZED_OPTIONS = [:alpha]
14
+
15
+ ALPHA_2 = [
16
+ 'AF', 'AX', 'AL', 'DZ', 'AS', 'AD', 'AO', 'AI', 'AQ', 'AG',
17
+ 'AR', 'AM', 'AW', 'AU', 'AT', 'AZ', 'BS', 'BH', 'BD', 'BB',
18
+ 'BY', 'BE', 'BZ', 'BJ', 'BM', 'BT', 'BO', 'BQ', 'BA', 'BW',
19
+ 'BV', 'BR', 'IO', 'BN', 'BG', 'BF', 'BI', 'CV', 'KH', 'CM',
20
+ 'CA', 'KY', 'CF', 'TD', 'CL', 'CN', 'CX', 'CC', 'CO', 'KM',
21
+ 'CG', 'CD', 'CK', 'CR', 'CI', 'HR', 'CU', 'CW', 'CY', 'CZ',
22
+ 'DK', 'DJ', 'DM', 'DO', 'EC', 'EG', 'SV', 'GQ', 'ER', 'EE',
23
+ 'SZ', 'ET', 'FK', 'FO', 'FJ', 'FI', 'FR', 'GF', 'PF', 'TF',
24
+ 'GA', 'GM', 'GE', 'DE', 'GH', 'GI', 'GR', 'GL', 'GD', 'GP',
25
+ 'GU', 'GT', 'GG', 'GN', 'GW', 'GY', 'HT', 'HM', 'VA', 'HN',
26
+ 'HK', 'HU', 'IS', 'IN', 'ID', 'IR', 'IQ', 'IE', 'IM', 'IL',
27
+ 'IT', 'JM', 'JP', 'JE', 'JO', 'KZ', 'KE', 'KI', 'KP', 'KR',
28
+ 'KW', 'KG', 'LA', 'LV', 'LB', 'LS', 'LR', 'LY', 'LI', 'LT',
29
+ 'LU', 'MO', 'MG', 'MW', 'MY', 'MV', 'ML', 'MT', 'MH', 'MQ',
30
+ 'MR', 'MU', 'YT', 'MX', 'FM', 'MD', 'MC', 'MN', 'ME', 'MS',
31
+ 'MA', 'MZ', 'MM', 'NA', 'NR', 'NP', 'NL', 'NC', 'NZ', 'NI',
32
+ 'NE', 'NG', 'NU', 'NF', 'MK', 'MP', 'NO', 'OM', 'PK', 'PW',
33
+ 'PS', 'PA', 'PG', 'PY', 'PE', 'PH', 'PN', 'PL', 'PT', 'PR',
34
+ 'QA', 'RE', 'RO', 'RU', 'RW', 'BL', 'SH', 'KN', 'LC', 'MF',
35
+ 'PM', 'VC', 'WS', 'SM', 'ST', 'SA', 'SN', 'RS', 'SC', 'SL',
36
+ 'SG', 'SX', 'SK', 'SI', 'SB', 'SO', 'ZA', 'GS', 'SS', 'ES',
37
+ 'LK', 'SD', 'SR', 'SJ', 'SE', 'CH', 'SY', 'TW', 'TJ', 'TZ',
38
+ 'TH', 'TL', 'TG', 'TK', 'TO', 'TT', 'TN', 'TR', 'TM', 'TC',
39
+ 'TV', 'UG', 'UA', 'AE', 'GB', 'US', 'UM', 'UY', 'UZ', 'VU',
40
+ 'VE', 'VN', 'VG', 'VI', 'WF', 'EH', 'YE', 'ZM', 'ZW'
41
+ ]
42
+
43
+ ALPHA_3 = [
44
+ 'AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG',
45
+ 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB',
46
+ 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA',
47
+ 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'CPV', 'KHM', 'CMR',
48
+ 'CAN', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM',
49
+ 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE',
50
+ 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST',
51
+ 'SWZ', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF',
52
+ 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP',
53
+ 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND',
54
+ 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR',
55
+ 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR',
56
+ 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU',
57
+ 'LUX', 'MAC', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ',
58
+ 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR',
59
+ 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC',
60
+ 'NER', 'NGA', 'NIU', 'NFK', 'MKD', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW',
61
+ 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI',
62
+ 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF',
63
+ 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE',
64
+ 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP',
65
+ 'LKA', 'SDN', 'SUR', 'SJM', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA',
66
+ 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA',
67
+ 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT',
68
+ 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE'
69
+ ]
70
+
71
+ def initialize(opts={})
72
+ if opts[:alpha].nil?
73
+ opts[:alpha] = 2
74
+ else
75
+ if opts[:alpha] != 2 and opts[:alpha] != 3
76
+ raise Saphyr::Error.new 'Bad county alpha option must be : 2 or 3'
77
+ end
78
+ end
79
+ super opts
80
+ end
81
+
82
+ private
83
+
84
+ def do_validate(ctx, name, value, errors)
85
+ return unless assert_not_empty value, errors
86
+ if @opts[:alpha] == 2
87
+ add_error value, errors unless ALPHA_2.include? value
88
+ else
89
+ add_error value, errors unless ALPHA_3.include? value
90
+ end
91
+ end
92
+
93
+ def add_error(value, errors)
94
+ errors << {
95
+ type: err('invalid'),
96
+ data: {
97
+ _val: value
98
+ }
99
+ }
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,114 @@
1
+ module Saphyr
2
+ module Fields
3
+
4
+ # The +IsoLang+ field type (ISO-639-1/2).
5
+ #
6
+ # Allowed options is: +:version with possible values: 1 or 2+
7
+ #
8
+ # - +1+ : Mean ISO-639-1 (default)
9
+ # - +2+ : Mean ISO-639-2
10
+ class IsoLangField < FieldBase
11
+ PREFIX = 'iso-lang'
12
+ EXPECTED_TYPES = String
13
+ AUTHORIZED_OPTIONS = [:version]
14
+
15
+ VERSION_1 = [
16
+ 'aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az',
17
+ 'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'ce',
18
+ 'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee',
19
+ 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr',
20
+ 'fy', 'ga', 'gd', 'gl', 'gn', 'gu', 'gv', 'ha', 'he', 'hi', 'ho', 'hr',
21
+ 'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'io', 'is',
22
+ 'it', 'iu', 'ja', 'jv', 'ka', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn',
23
+ 'ko', 'kr', 'ks', 'ku', 'kv', 'kw', 'ky', 'la', 'lb', 'lg', 'li', 'ln',
24
+ 'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk', 'ml', 'mn', 'mr', 'ms',
25
+ 'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng', 'nl', 'nn', 'no', 'nr', 'nv',
26
+ 'ny', 'oc', 'oj', 'om', 'or', 'os', 'pa', 'pi', 'pl', 'ps', 'pt', 'qu',
27
+ 'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc', 'sd', 'se', 'sg', 'si', 'sk',
28
+ 'sl', 'sm', 'sn', 'so', 'sq', 'sr', 'ss', 'st', 'su', 'sv', 'sw', 'ta',
29
+ 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tr', 'ts', 'tt', 'tw',
30
+ 'ty', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'wo', 'xh', 'yi',
31
+ 'yo', 'za', 'zh', 'zu'
32
+ ]
33
+
34
+ VERSION_2 = [
35
+ 'aar', 'abk', 'ace', 'ach', 'ada', 'ady', 'afa', 'afh', 'afr', 'ain', 'aka',
36
+ 'akk', 'alb', 'ale', 'alg', 'alt', 'amh', 'ang', 'anp', 'apa', 'ara', 'arc',
37
+ 'arg', 'arm', 'arn', 'arp', 'art', 'arw', 'asm', 'ast', 'ath', 'aus', 'ava',
38
+ 'ave', 'awa', 'aym', 'aze', 'bad', 'bai', 'bak', 'bal', 'bam', 'ban', 'baq',
39
+ 'bas', 'bat', 'bej', 'bel', 'bem', 'ben', 'ber', 'bho', 'bih', 'bik', 'bin',
40
+ 'bis', 'bla', 'bnt', 'bos', 'bra', 'bre', 'btk', 'bua', 'bug', 'bul', 'bur',
41
+ 'byn', 'cad', 'cai', 'car', 'cat', 'cau', 'ceb', 'cel', 'cha', 'chb', 'che',
42
+ 'chg', 'chi', 'chk', 'chm', 'chn', 'cho', 'chp', 'chr', 'chu', 'chv', 'chy',
43
+ 'cmc', 'cnr', 'cop', 'cor', 'cos', 'cpe', 'cpf', 'cpp', 'cre', 'crh', 'crp',
44
+ 'csb', 'cus', 'cze', 'dak', 'dan', 'dar', 'day', 'del', 'den', 'dgr', 'din',
45
+ 'div', 'doi', 'dra', 'dsb', 'dua', 'dum', 'dut', 'dyu', 'dzo', 'efi', 'egy',
46
+ 'eka', 'elx', 'eng', 'enm', 'epo', 'est', 'ewe', 'ewo', 'fan', 'fao', 'fat',
47
+ 'fij', 'fil', 'fin', 'fiu', 'fon', 'fre', 'frm', 'fro', 'frr', 'frs', 'fry',
48
+ 'ful', 'fur', 'gaa', 'gay', 'gba', 'gem', 'geo', 'ger', 'gez', 'gil', 'gla',
49
+ 'gle', 'glg', 'glv', 'gmh', 'goh', 'gon', 'gor', 'got', 'grb', 'grc', 'gre',
50
+ 'grn', 'gsw', 'guj', 'gwi', 'hai', 'hat', 'hau', 'haw', 'heb', 'her', 'hil',
51
+ 'him', 'hin', 'hit', 'hmn', 'hmo', 'hrv', 'hsb', 'hun', 'hup', 'iba', 'ibo',
52
+ 'ice', 'ido', 'iii', 'ijo', 'iku', 'ile', 'ilo', 'ina', 'inc', 'ind', 'ine',
53
+ 'inh', 'ipk', 'ira', 'iro', 'ita', 'jav', 'jbo', 'jpn', 'jpr', 'jrb', 'kaa',
54
+ 'kab', 'kac', 'kal', 'kam', 'kan', 'kar', 'kas', 'kau', 'kaw', 'kaz', 'kbd',
55
+ 'kha', 'khi', 'khm', 'kho', 'kik', 'kin', 'kir', 'kmb', 'kok', 'kom', 'kon',
56
+ 'kor', 'kos', 'kpe', 'krc', 'krl', 'kro', 'kru', 'kua', 'kum', 'kur', 'kut',
57
+ 'lad', 'lah', 'lam', 'lao', 'lat', 'lav', 'lez', 'lim', 'lin', 'lit', 'lol',
58
+ 'loz', 'ltz', 'lua', 'lub', 'lug', 'lui', 'lun', 'luo', 'lus', 'mac', 'mad',
59
+ 'mag', 'mah', 'mai', 'mak', 'mal', 'man', 'mao', 'map', 'mar', 'mas', 'may',
60
+ 'mdf', 'mdr', 'men', 'mga', 'mic', 'min', 'mis', 'mkh', 'mlg', 'mlt', 'mnc',
61
+ 'mni', 'mno', 'moh', 'mon', 'mos', 'mul', 'mun', 'mus', 'mwl', 'mwr', 'myn',
62
+ 'myv', 'nah', 'nai', 'nap', 'nau', 'nav', 'nbl', 'nde', 'ndo', 'nds', 'nep',
63
+ 'new', 'nia', 'nic', 'niu', 'nno', 'nob', 'nog', 'non', 'nor', 'nqo', 'nso',
64
+ 'nub', 'nwc', 'nya', 'nym', 'nyn', 'nyo', 'nzi', 'oci', 'oji', 'ori', 'orm',
65
+ 'osa', 'oss', 'ota', 'oto', 'paa', 'pag', 'pal', 'pam', 'pan', 'pap', 'pau',
66
+ 'peo', 'per', 'phi', 'phn', 'pli', 'pol', 'pon', 'por', 'pra', 'pro', 'pus',
67
+ 'qaa', 'que', 'raj', 'rap', 'rar', 'roa', 'roh', 'rom', 'rum', 'run', 'rup',
68
+ 'rus', 'sad', 'sag', 'sah', 'sai', 'sal', 'sam', 'san', 'sas', 'sat', 'scn',
69
+ 'sco', 'sel', 'sem', 'sga', 'sgn', 'shn', 'sid', 'sin', 'sio', 'sit', 'sla',
70
+ 'slo', 'slv', 'sma', 'sme', 'smi', 'smj', 'smn', 'smo', 'sms', 'sna', 'snd',
71
+ 'snk', 'sog', 'som', 'son', 'sot', 'spa', 'srd', 'srn', 'srp', 'srr', 'ssa',
72
+ 'ssw', 'suk', 'sun', 'sus', 'sux', 'swa', 'swe', 'syc', 'syr', 'tah', 'tai',
73
+ 'tam', 'tat', 'tel', 'tem', 'ter', 'tet', 'tgk', 'tgl', 'tha', 'tib', 'tig',
74
+ 'tir', 'tiv', 'tkl', 'tlh', 'tli', 'tmh', 'tog', 'ton', 'tpi', 'tsi', 'tsn',
75
+ 'tso', 'tuk', 'tum', 'tup', 'tur', 'tut', 'tvl', 'twi', 'tyv', 'udm', 'uga',
76
+ 'uig', 'ukr', 'umb', 'und', 'urd', 'uzb', 'vai', 'ven', 'vie', 'vol', 'vot',
77
+ 'wak', 'wal', 'war', 'was', 'wel', 'wen', 'wln', 'wol', 'xal', 'xho', 'yao',
78
+ 'yap', 'yid', 'yor', 'ypk', 'zap', 'zbl', 'zen', 'zgh', 'zha', 'znd', 'zul',
79
+ 'zun', 'zxx', 'zza'
80
+ ]
81
+
82
+ def initialize(opts={})
83
+ if opts[:version].nil?
84
+ opts[:version] = 1
85
+ else
86
+ if opts[:version] != 1 and opts[:version] != 2
87
+ raise Saphyr::Error.new 'Bad language akpha option must be : 2 or 3'
88
+ end
89
+ end
90
+ super opts
91
+ end
92
+
93
+ private
94
+
95
+ def do_validate(ctx, name, value, errors)
96
+ return unless assert_not_empty value, errors
97
+ if @opts[:version] == 1
98
+ add_error value, errors unless VERSION_1.include? value
99
+ else
100
+ add_error value, errors unless VERSION_2.include? value
101
+ end
102
+ end
103
+
104
+ def add_error(value, errors)
105
+ errors << {
106
+ type: err('invalid'),
107
+ data: {
108
+ _val: value
109
+ }
110
+ }
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,29 @@
1
+ require 'uri'
2
+
3
+ module Saphyr
4
+ module Fields
5
+
6
+ # The +URI+ field type
7
+ #
8
+ # No options are allowed.
9
+ class UriField < FieldBase
10
+ PREFIX = 'uri'
11
+ EXPECTED_TYPES = String
12
+
13
+ private
14
+
15
+ def do_validate(ctx, name, value, errors)
16
+ begin
17
+ URI.parse value
18
+ rescue URI::InvalidURIError
19
+ errors << {
20
+ type: err('invalid'),
21
+ data: {
22
+ _val: value
23
+ }
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ require 'uri'
2
+
3
+ module Saphyr
4
+ module Fields
5
+
6
+ # The +URL+ field type
7
+ #
8
+ # No options are allowed.
9
+ class UrlField < FieldBase
10
+ PREFIX = 'url'
11
+ EXPECTED_TYPES = String
12
+
13
+ private
14
+
15
+ def do_validate(ctx, name, value, errors)
16
+ begin
17
+ uri = URI.parse value
18
+ unless uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
19
+ add_error value, errors
20
+ end
21
+ rescue URI::InvalidURIError
22
+ add_error value, errors
23
+ end
24
+ end
25
+
26
+ def add_error(value, errors)
27
+ errors << {
28
+ type: err('invalid'),
29
+ data: {
30
+ _val: value
31
+ }
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
data/lib/saphyr/fields.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  module Saphyr
2
2
  module Fields
3
3
  require_relative './fields/field_base'
4
-
5
4
  require_relative './fields/array_field'
6
5
  require_relative './fields/schema_field'
7
6
 
@@ -9,5 +8,13 @@ module Saphyr
9
8
  require_relative './fields/integer_field'
10
9
  require_relative './fields/float_field'
11
10
  require_relative './fields/boolean_field'
11
+ require_relative './fields/email_field'
12
+ require_relative './fields/uri_field'
13
+ require_relative './fields/url_field'
14
+ require_relative './fields/b64_field'
15
+ require_relative './fields/ip_field'
16
+ require_relative './fields/iso_country_field'
17
+ require_relative './fields/iso_lang_field'
18
+ require_relative './fields/datetime_field'
12
19
  end
13
20
  end
@@ -98,6 +98,13 @@ module Saphyr
98
98
  return 'Conditional field not allowed'
99
99
  end
100
100
 
101
+ # ------------------------------------
102
+ # Not Empty
103
+ # ------------------------------------
104
+ if type.end_with? 'not-empty'
105
+ return 'Cannot be empty'
106
+ end
107
+
101
108
  # ------------------------------------
102
109
  # Not Nullable
103
110
  # ------------------------------------
@@ -105,6 +112,14 @@ module Saphyr
105
112
  return 'Not nullable'
106
113
  end
107
114
 
115
+ # ------------------------------------
116
+ # Common
117
+ # ------------------------------------
118
+ # invalid
119
+ if type.end_with? 'invalid'
120
+ return "Invalid format, got: '#{data[:_val]}'"
121
+ end
122
+
108
123
  'unknown'
109
124
  end
110
125
  end
@@ -95,7 +95,7 @@ module Saphyr
95
95
  # -----
96
96
 
97
97
  # Validate an already parsed JSON document.
98
- # @param [Hash | Array] The data to validate.
98
+ # @param data [Hash | Array] The data to validate.
99
99
  # @return [Boolean] Wheter the validation was successful or failed.
100
100
  def validate(data)
101
101
  @ctx = Saphyr::Engine::Context.new [self], get_config, data, nil, '//'
@@ -119,11 +119,80 @@ module Saphyr
119
119
  end
120
120
 
121
121
  # Get a field from the data to validate.
122
- # @param [String | Symbol] The field name
122
+ #
123
+ # Use variadic arguments to access deep fields.
124
+ #
125
+ # Examples:
126
+ #
127
+ # data = {
128
+ # "id" => 3465,
129
+ # "info" => {
130
+ # "suffix" => ["gif", "jpg", "png"]
131
+ # "size" => 34056
132
+ # }
133
+ # }
134
+ #
135
+ # get("id") # => 3435
136
+ # get("info", "suffix", 1) # => "jpg"
137
+ # get("info", "size") # => 34056
138
+ # get("name") # => raise an exception
139
+ #
123
140
  # @return The field value
124
- def get(field)
125
- data = @ctx.data_to_validate
126
- data[field.to_s]
141
+ # @raise [Saphyr::Error] If field does not exists.
142
+ def get(*args)
143
+ status, value = get_safe(*args)
144
+ raise Saphyr::Error.new 'Requested field does not exists' if status == :err
145
+ value
146
+ end
147
+
148
+ # Get a field from the data to validate.
149
+ # (Same as +get()+ but never raise an exception).
150
+ #
151
+ # Use variadic arguments to access deep fields.
152
+ #
153
+ # Examples:
154
+ #
155
+ # data = {
156
+ # "id" => 3465,
157
+ # "info" => {
158
+ # "suffix" => ["gif", "jpg", "png"]
159
+ # "size" => 34056
160
+ # }
161
+ # }
162
+ #
163
+ # get("id") # => [:ok, 3435]
164
+ # get("info", "suffix", 1) # => [:ok, "jpg"]
165
+ # get("info", "size") # => [:ok, 34056]
166
+ # get("name") # => [:err, :not_exists]
167
+ # get("info", "suffix", 5) # => [:err, :not_index]
168
+ # get("info", 3) # => [:err, :not_array]
169
+ #
170
+ # @return An array where first element is the status and second element is the result.
171
+ def get_safe(*args)
172
+ do_get_safe @data, args.reverse
173
+ end
174
+
175
+ private
176
+
177
+ def do_get_safe(data, args)
178
+ return [:ok, data] if args.size == 0
179
+ key = args.pop
180
+ if data.is_a? Hash
181
+ key = key.to_s if key.is_a? Symbol
182
+ if data.key? key
183
+ return do_get_safe data[key], args
184
+ else
185
+ return [:err, :not_exists]
186
+ end
187
+ elsif data.is_a? Array
188
+ if key.is_a? Integer
189
+ return do_get_safe data[key], args
190
+ else
191
+ return [:err, :not_index]
192
+ end
193
+ else
194
+ return [:err, :not_array]
195
+ end
127
196
  end
128
197
  end
129
198
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Saphyr
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.1'
5
5
  end
data/lib/saphyr.rb CHANGED
@@ -157,4 +157,12 @@ Saphyr.register do
157
157
  field_type :integer, Saphyr::Fields::IntegerField
158
158
  field_type :float, Saphyr::Fields::FloatField
159
159
  field_type :boolean, Saphyr::Fields::BooleanField
160
+ field_type :email, Saphyr::Fields::EmailField
161
+ field_type :uri, Saphyr::Fields::UriField
162
+ field_type :url, Saphyr::Fields::UrlField
163
+ field_type :b64, Saphyr::Fields::B64Field
164
+ field_type :ip, Saphyr::Fields::IpField
165
+ field_type :iso_country, Saphyr::Fields::IsoCountryField
166
+ field_type :iso_lang, Saphyr::Fields::IsoLangField
167
+ field_type :datetime, Saphyr::Fields::DateTimeField
160
168
  end
@@ -4,7 +4,7 @@ By default the `Saphyr` library is including many field types.
4
4
 
5
5
  ## Common options
6
6
 
7
- All field type have the common `:required`, `:nullable` and `:nullable` options.
7
+ All field type have the common `:required`, `:nullable` and `:default` options.
8
8
 
9
9
  ## String
10
10
 
@@ -15,16 +15,14 @@ Here is an example with all possible options for `:string` type:
15
15
  ```ruby
16
16
  class MyValidator < Saphyr::Validator
17
17
  field :name, :string
18
- field :name, :string, eq: 'v1.1' # Field name can be a
19
- field "name", :string, min: 5, max: 50 # Symbol or a String
20
- field "name", :string, max: 50
21
- field "name", :string, len: 15
22
- field :name, :string, len: 15, regexp: /^[a-f0-9]+$/
23
- field :name, :string, regexp: /^[A-Z0-9]{15}$/
24
- field :name, :string, in: ['jpg', 'png', 'gif']
25
-
26
-
27
- field :location, :string, required: false, min: 10
18
+ field :version, :string, eq: 'v1.1' # Field name can be a
19
+ field "fname", :string, min: 5, max: 50 # Symbol or a String
20
+ field "lname", :string, max: 50
21
+ field "info", :string, len: 15
22
+ field :hexa, :string, len: 15, regexp: /^[a-f0-9]+$/
23
+ field :nid, :string, regexp: /^[A-Z0-9]{15}$/
24
+ field :extension, :string, in: ['jpg', 'png', 'gif']
25
+ field :location, :string, required: false, min: 10, default: 'here'
28
26
  field :info, :string, nullable: true, max: 1024
29
27
  end
30
28
  ```
@@ -33,7 +31,6 @@ end
33
31
  - If you use `:len` option then you cannot use `:min` and `:max` options
34
32
  - If you use `:in` option then you cannot use any of the other options
35
33
 
36
-
37
34
  ## Integer
38
35
 
39
36
  Authorized options for the `:integer` type: `[:eq, :gt, :gte, :lt, :lte, :in]`
@@ -42,15 +39,14 @@ Here is an example with all possible options for `:integer` type:
42
39
 
43
40
  ```ruby
44
41
  class MyValidator < Saphyr::Validator
45
- field :name, :integer
46
- field :name, :integer, eq: 'v1.1'
47
- field :name, :integer, gt: 0
48
- field :name, :integer, lt: 50
49
- field :name, :integer, gte: 5, lte: 50
50
- field :name, :integer, in: ['jpg', 'png', 'gif']
51
-
52
- field :count, :integer, required: false, gte: 10
53
- field :round, :integer, nullable: true, lte: 1024
42
+ field :id, :integer, gt: 0
43
+ field :nb, :integer
44
+ field :version, :integer, eq: '101'
45
+ field :value, :integer, lt: 50
46
+ field :range, :integer, gte: 5, lte: 50
47
+ field :velocity, :integer, in: [10, 20, 30, 40]
48
+ field :count, :integer, required: false, gte: 10, default: 20
49
+ field :round, :integer, nullable: true, lte: 1024
54
50
  end
55
51
  ```
56
52
 
@@ -65,14 +61,13 @@ Here is an example with all possible options for `:float` type:
65
61
 
66
62
  ```ruby
67
63
  class MyValidator < Saphyr::Validator
68
- field :name, :float
69
- field :name, :float, eq: 15.1
70
- field :name, :float, gt: 0
71
- field :name, :float, lt: 50
72
- field :name, :float, gte: 5, lte: 50
73
- field :name, :float, in: ['jpg', 'png', 'gif']
74
-
75
- field :price, :float, required: false, gte: 10
64
+ field :value, :float
65
+ field :velocity, :float, eq: 15.1
66
+ field :x_axis, :float, gt: 0.0
67
+ field :y_axis, :float, lt: 50
68
+ field :z_axis, :float, gte: 5, lte: 50
69
+ field :focale, :float, in: [3.14, 1.618, 6.35]
70
+ field :price, :float, required: false, gte: 10, default: 22.2
76
71
  field :discount, :float, nullable: true, lte: 1024
77
72
  end
78
73
  ```
@@ -88,15 +83,123 @@ Here is an example with all possible options for `:boolean` type:
88
83
 
89
84
  ```ruby
90
85
  class MyValidator < Saphyr::Validator
91
- field :name, :boolean
92
- field :name, :boolean, eq: true
93
- field :name, :boolean, eq: false
94
-
95
- field :active, :boolean, required: false
86
+ field :payed, :boolean
87
+ field :valid, :boolean, eq: true
88
+ field :option, :boolean, eq: false
89
+ field :active, :boolean, required: false, default: true
96
90
  field :processed, :boolean, nullable: true
97
91
  end
98
92
  ```
99
93
 
94
+ ## Email
95
+
96
+ No options allowed for the `:email` type.
97
+
98
+ ```ruby
99
+ class MyValidator < Saphyr::Validator
100
+ field :email, :email
101
+ end
102
+ ```
103
+
104
+ ## URI and URL
105
+
106
+ No options allowed for the `:uri` and `:url` types.
107
+
108
+ ```ruby
109
+ class MyValidator < Saphyr::Validator
110
+ field :email, :uri # valid@email.com
111
+ field :isbn, :uri # urn:isbn:0451450523
112
+ field :location, :uri # https://example.com/page.html
113
+
114
+ field :site, :url # http://www.test.com/
115
+ field :blog, :url # http://test.com/page.html
116
+ end
117
+ ```
118
+
119
+ ## Base64
120
+
121
+ Authorized options for the `:b64` type: `[:strict]`
122
+
123
+ Here is an example with all possible options for `:b64` type:
124
+
125
+ ```ruby
126
+ class MyValidator < Saphyr::Validator
127
+ field :content, :b64 # By default :strict == true
128
+ field :text, :b64, strict: false
129
+ end
130
+ ```
131
+
132
+ In strict mode `:strict == true`:
133
+
134
+ - Line breaks are not allowed
135
+ - Padding must be correct (length % 4 == 0)
136
+
137
+ Not in strict mode `:strict == false`:
138
+
139
+ - Line breaks are allowed
140
+ - Padding is not required
141
+
142
+ ## IP
143
+
144
+ Authorized options for the `:ip` type: `[:kind]`
145
+
146
+ Here is an example with all possible options for `:ip` type:
147
+
148
+ ```ruby
149
+ class MyValidator < Saphyr::Validator
150
+ field :web1, :ip # Can be ipv4 or ipv6
151
+ field :db, :ip, kind: :ipv4 # Must be an ipv4
152
+ field :cache, :ip, kind: :ipv6 # Must be an ipv6
153
+ end
154
+ ```
155
+
156
+ ## Country (ISO-3166-1 alpha 2/3)
157
+
158
+ Authorized options for the `:iso_country` type: `[:alpha]`
159
+
160
+ Here is an example with all possible options for `:iso_country` type:
161
+
162
+ ```ruby
163
+ class MyValidator < Saphyr::Validator
164
+ field :country1, :iso_country # Default : ISO-3166-1 alpha-2
165
+ field :country2, :iso_country, alpha: 2
166
+ field :country3, :iso_country, alpha: 3
167
+ end
168
+ ```
169
+
170
+ - `:alpha = 2` : Mean ISO-3166-1 alpha-2
171
+ - `:alpha = 3` : Mean ISO-3166-1 alpha-3
172
+
173
+ ## Language (ISO-639-1, ISO-639-2)
174
+
175
+ Authorized options for the `:iso_lang` type: `[:version]`
176
+
177
+ Here is an example with all possible options for `:iso_lang` type:
178
+
179
+ ```ruby
180
+ class MyValidator < Saphyr::Validator
181
+ field :lang1, :iso_lang # Default : ISO-639-1
182
+ field :lang2, :iso_lang, version: 1
183
+ field :lang3, :iso_lang, version: 2
184
+ end
185
+ ```
186
+
187
+ - `:version = 1` : Mean ISO-639-1
188
+ - `:version = 2` : Mean ISO-639-2
189
+
190
+ ## DateTime
191
+
192
+ Authorized options for the `:datetime` type: `[:format]`
193
+
194
+ Here is an example with all possible options for `:format` type:
195
+
196
+ ```ruby
197
+ class MyValidator < Saphyr::Validator
198
+ field :datetime1, :datetime # Any valid format
199
+ field :datetime2, :datetime, format: '%d/%m/%Y %H:%M:%S'
200
+ end
201
+ ```
202
+
100
203
  ## Array
101
204
 
102
205
  Authorized options for the `:array` type: `[:len, :min, :max, :of_type, :of_schema, :opts]`
@@ -127,7 +230,7 @@ class MyValidator < Saphyr::Validator
127
230
  # | |
128
231
  # Size of array must be: 1 >= s <= 10 |
129
232
  # |
130
- # This 'opts' are for the element of array, ie: 'string'
233
+ # This 'opts' are for the elements of the array, ie: 'string' type
131
234
  end
132
235
  ```
133
236
 
@@ -147,7 +250,7 @@ data = {
147
250
  class MyValidator < Saphyr::Validator
148
251
  schema :tag do
149
252
  field :id, :integer, gt: 0
150
- field :label, :string, min: 5, max: 30
253
+ field :label, :string, min: 2, max: 30
151
254
  end
152
255
 
153
256
  field :code, :string, min: 5, max: 10
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saphyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - odelbos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-21 00:00:00.000000000 Z
11
+ date: 2025-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
- description: The purpose of Saphyr is to provide a nice and simple DSL to easily and
42
- quickly design a validation schema for JSON document.
41
+ description: Simple DSL to design validation schemas for JSON document (or Hash /
42
+ Array structure)
43
43
  email:
44
44
  - od@phibox.com
45
45
  executables: []
@@ -64,12 +64,20 @@ files:
64
64
  - lib/saphyr/engine.rb
65
65
  - lib/saphyr/fields.rb
66
66
  - lib/saphyr/fields/array_field.rb
67
+ - lib/saphyr/fields/b64_field.rb
67
68
  - lib/saphyr/fields/boolean_field.rb
69
+ - lib/saphyr/fields/datetime_field.rb
70
+ - lib/saphyr/fields/email_field.rb
68
71
  - lib/saphyr/fields/field_base.rb
69
72
  - lib/saphyr/fields/float_field.rb
70
73
  - lib/saphyr/fields/integer_field.rb
74
+ - lib/saphyr/fields/ip_field.rb
75
+ - lib/saphyr/fields/iso_country_field.rb
76
+ - lib/saphyr/fields/iso_lang_field.rb
71
77
  - lib/saphyr/fields/schema_field.rb
72
78
  - lib/saphyr/fields/string_field.rb
79
+ - lib/saphyr/fields/uri_field.rb
80
+ - lib/saphyr/fields/url_field.rb
73
81
  - lib/saphyr/helpers.rb
74
82
  - lib/saphyr/helpers/format.rb
75
83
  - lib/saphyr/schema.rb
@@ -93,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
101
  requirements:
94
102
  - - ">="
95
103
  - !ruby/object:Gem::Version
96
- version: 2.6.0
104
+ version: 2.7.0
97
105
  required_rubygems_version: !ruby/object:Gem::Requirement
98
106
  requirements:
99
107
  - - ">="
@@ -103,5 +111,6 @@ requirements: []
103
111
  rubygems_version: 3.5.6
104
112
  signing_key:
105
113
  specification_version: 4
106
- summary: The saphyr gem is used to validate JSON document.
114
+ summary: Simple DSL to design validation schemas for JSON document (or Hash / Array
115
+ structure)
107
116
  test_files: []