simple_validate 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f7051ee7f5fc5cec9a9f1f7e4859b6145172302ba667b71d11710b7ca34ad1e
4
- data.tar.gz: bfbbc3767ffee4d622411b1fd1673e32710ceeb611d588e7fa34799e23aa092e
3
+ metadata.gz: 633fbb10accca5c33bc717619ef5392f40f53ffea6ccf4dc9e62fa19f934287c
4
+ data.tar.gz: 3a93d9d8e9e9fb896dd150f7137893694339c005b87953f5c2c5d6b6e5f03a90
5
5
  SHA512:
6
- metadata.gz: 8721e31ba42d72dc48e2690284676930b50c6a9ad6765105e36d51a6c9d068ea8804e1bbfe83424a3d0b725b9a39b19a7cd65f0afe14fe8129da0e66d97d44e6
7
- data.tar.gz: 6e0c1805d7e4027ecb6fec0b4d727a99ef02c0fbe33e9c0e54c2f0f92843de516d63dcf095c31c6b3bfc396f4b7f6258285df8522a056cc531e38cce09343b21
6
+ metadata.gz: '070947710fb4ceecf88974d5126073b8f02b37af1cd185d02e6019281934836655733b6f622bc2ac47f4dba8f5c68eac1c8f8ba4d27f0f31f25d6a01234bc35c'
7
+ data.tar.gz: 81ecd04c13e0ef128b16aa7fbce0c845e86dabcc259f9c61f5ad066058359c5a6ca4867360cfa9e65d86ab699975a1554c01fad7ad31970278ca2ea51a7c7285
data/.rspec_status CHANGED
@@ -1,4 +1,8 @@
1
1
  example_id | status | run_time |
2
2
  ------------------------------------- | ------ | --------------- |
3
- ./spec/simple_validate_spec.rb[1:1:1] | passed | 0.00136 seconds |
4
- ./spec/simple_validate_spec.rb[1:2:1] | passed | 0.00034 seconds |
3
+ ./spec/simple_validate_spec.rb[1:1:1] | passed | 0.00127 seconds |
4
+ ./spec/simple_validate_spec.rb[1:2:1] | passed | 0.00012 seconds |
5
+ ./spec/simple_validate_spec.rb[1:3:1] | passed | 0.00104 seconds |
6
+ ./spec/simple_validate_spec.rb[1:4:1] | passed | 0.00009 seconds |
7
+ ./spec/simple_validate_spec.rb[1:5:1] | passed | 0.00006 seconds |
8
+ ./spec/simple_validate_spec.rb[1:6:1] | passed | 0.00005 seconds |
@@ -20,6 +20,10 @@ module SimpleValidate
20
20
  @messages.fetch(key)
21
21
  end
22
22
 
23
+ def clear!
24
+ @messages = {}
25
+ end
26
+
23
27
  def empty?
24
28
  @messages.empty?
25
29
  end
@@ -53,7 +53,7 @@ module SimpleValidate
53
53
  raise InvalidLengthOption, "Invalid length option given #{options.keys}"
54
54
  end
55
55
 
56
- actual_length = instance.send(attribute).length
56
+ actual_length = instance.send(attribute)&.length
57
57
  valid_length?(actual_length)
58
58
  end
59
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleValidate
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.2"
5
5
  end
@@ -67,6 +67,8 @@ module SimpleValidate
67
67
  end
68
68
 
69
69
  def validate(instance)
70
+ instance.errors.clear!
71
+
70
72
  validations.each do |validation|
71
73
  if validation.condition.call && !validation.valid?(instance)
72
74
  instance.errors.add(validation.attribute, validation.message)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_validate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Palaniuk