is_valid 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/is_valid.rb +6 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52d7f0c269773fca0004890f533913e50b3890e346fa61790e32b81999f3d8a6
|
4
|
+
data.tar.gz: 4416eb822c8700d12e31c1df142bfaa36e556fdbc4470634d3ab2ac1970b4a33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0886da35af820bb8545b0a064f68e82fe6fc353cd471e771d4abb76f0095a305fa984754f89e367cf837ecd96a52e037f375a86a89f8a38614725c53281f2990'
|
7
|
+
data.tar.gz: 3d80dcaf9873382298d3bdaf61addaa5a2d4cfedf711008e4ee6a90ad0eb6d2e27d00cc64d4572bee723178c0299dc53d828e54d3831b5d52b59e761c4031d76
|
data/lib/is_valid.rb
CHANGED
@@ -8,13 +8,18 @@ class IsValid
|
|
8
8
|
sentence: '^(\w| |,)+(\.|!|\?)$',
|
9
9
|
boolean: '^(1|0|true|false)$',
|
10
10
|
url: '^(http://|https://)(.)+\.(.)+$',
|
11
|
+
email: '^([a-z,A-Z,\-,\_,\.]*)@(.*)+\.(.*)$',
|
12
|
+
any: '(.*)+',
|
13
|
+
nil: nil
|
11
14
|
}
|
12
15
|
@rules = @rules.merge(rules)
|
13
16
|
@templates = templates
|
14
17
|
end
|
15
18
|
|
16
19
|
def check(var, rule_name)
|
17
|
-
var.to_s.match?(@rules[rule_name.to_sym])
|
20
|
+
res = @rules[rule_name.to_sym].nil? ? var.nil? : var.to_s.match?(@rules[rule_name.to_sym])
|
21
|
+
res = var.nil? if !res && rule_name.to_a.last == '*'
|
22
|
+
res
|
18
23
|
end
|
19
24
|
|
20
25
|
def check_hash(hash_var, template)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: is_valid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergei Illarionov (www.butteff.ru/en/)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby Gem to make a validation of a variable or a hash, based on regular
|
14
14
|
expressions or own predefined validation templates in an easy way. See full documentation
|
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
|
-
rubygems_version: 3.
|
42
|
+
rubygems_version: 3.4.19
|
43
43
|
signing_key:
|
44
44
|
specification_version: 4
|
45
45
|
summary: Validation of a variable or a hash, based on predefined or own easy rules
|