anyvali 1.1.6 → 1.1.7
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 +4 -4
- data/lib/anyvali/format/validators.rb +8 -2
- data/lib/anyvali/parse/coercion.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c292fcbdc9347a47f66b5e9fcd45a5ebdb8dd647fc4b756810f389aa14425636
|
|
4
|
+
data.tar.gz: 4c4a8d393839e273462d085c1414f40e61652af7b934c73439bc575bc4e37dc9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c88cada8d52e7f650004a3cb5f12e880a2755b644b9f2b105c953ec62454b49a4dde1d2451c57afab7101ea56cf7688ea10aa293ac4509f4734d7ba74a2b438
|
|
7
|
+
data.tar.gz: 002ffdd02a6d7fb5e1e499ec04bd602d8c66bc782f1b912e910e1cec21b769a9a70ac232cf95fec2633bb894b3f19d2a9a6d1f56bec66859c68e6482858ecc76
|
|
@@ -7,7 +7,6 @@ require "date"
|
|
|
7
7
|
module AnyVali
|
|
8
8
|
module Format
|
|
9
9
|
module Validators
|
|
10
|
-
EMAIL_REGEX = /\A[^@\s]+@[^@\s]+\.[^@\s]+\z/
|
|
11
10
|
UUID_REGEX = /\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/i
|
|
12
11
|
# Strict IPv4: no leading zeros, octets 0-255
|
|
13
12
|
IPV4_REGEX = /\A(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\z/
|
|
@@ -39,7 +38,14 @@ module AnyVali
|
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
def valid_email?(value)
|
|
42
|
-
|
|
41
|
+
# The old regex could backtrack across repeated dots in the domain.
|
|
42
|
+
at = value.index("@")
|
|
43
|
+
return false unless at && at.positive? && at < value.length - 1 && at == value.rindex("@")
|
|
44
|
+
return false if /\s/.match?(value)
|
|
45
|
+
|
|
46
|
+
domain = value[(at + 1)..]
|
|
47
|
+
dot = domain.index(".", 1)
|
|
48
|
+
!dot.nil? && dot < domain.length - 1
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
def valid_url?(value)
|
|
@@ -78,7 +78,7 @@ module AnyVali
|
|
|
78
78
|
# Spec 5.1: parse DECIMAL floating-point only. Ruby's Float() also accepts
|
|
79
79
|
# digit-group underscores ("1_000.5") and hex floats ("0x1.8p3"), which
|
|
80
80
|
# diverge from the JS reference and let non-decimal strings slip through.
|
|
81
|
-
return { success: false, value: value } unless stripped.match?(/\A[+-]?(
|
|
81
|
+
return { success: false, value: value } unless stripped.match?(/\A[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?\z/)
|
|
82
82
|
|
|
83
83
|
begin
|
|
84
84
|
f = Float(stripped)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: anyvali
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- AnyVali Contributors
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|