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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/is_valid.rb +6 -1
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d272cc084b3fd71f900b36c56073cebd95caa37d58b056e655e09169d5d0065b
4
- data.tar.gz: 4aec2428e9c0c6a00764001076d40d8fa702da18632695f693459dfa494812b7
3
+ metadata.gz: 52d7f0c269773fca0004890f533913e50b3890e346fa61790e32b81999f3d8a6
4
+ data.tar.gz: 4416eb822c8700d12e31c1df142bfaa36e556fdbc4470634d3ab2ac1970b4a33
5
5
  SHA512:
6
- metadata.gz: cfdf5dc5d8c27dbf8228fdbd6f8fc452040561ca3459c76513e8cb7f8b5dd42d83ef0a7117515f36577c199616801959e8f60eb76a0c544052f4a29dded53a46
7
- data.tar.gz: 6e001d069f72c1d1cb5b53495076d053fab3fa7c283ce37cc6d69ae9f9659e8da2a7a9afc74181d098b471a051900de2b90b6fdfbbc87ac3e8882ef657b8b401
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.6
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-15 00:00:00.000000000 Z
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.3.15
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