effective_resources 1.3.12 → 1.3.13

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: 5a27a5d91ad9e8bee6b72ddf94fccc5c92a3e17971347160159f2829b3ffd154
4
- data.tar.gz: cfb62f2949aa38c117aaff73245f0cde9959f77dbc159d297b48bce3a0354c84
3
+ metadata.gz: 030a9151bd57835e2fb619e6217b6bfe6810a36a83576708f5123e7f3bf94344
4
+ data.tar.gz: d0f5871010a0cf031259f9faa87f5dcfcfae5b20f9f46f01dd7443f61df24c56
5
5
  SHA512:
6
- metadata.gz: 10a374fc9e41ecfafe13965f803db2a57075c3c78d34e92623a5248139e0655fae6d6bcca3ba6f1f605cd61cfc4121809a87b6d9bda31604edf772cf41bb74fa
7
- data.tar.gz: dc29913f068679af392e8f17d2fe5378d9a8a8f9a625404c7a3d46d800a8b676382bfe4a33fa40e1d3fbad5b98ca7beb68181891430b1a84bfe933f2faa350f2
6
+ metadata.gz: 441cdbde2ff803f24ff03eb1c3c5a5a13043d7c8d4c80a5f54ed9783d6f0531479c5fe00b0e88010925a1ead0994927996d853f52603e323d3c63c813d02bc81
7
+ data.tar.gz: 62476610060f57a6dffdf1ffa00bce7b3accfee61755165c299cad20e4fcddd3444907d68856b2a68cd7bc297392808884021699b89da4ccffedc418fa41cd1d
@@ -0,0 +1,13 @@
1
+ # An ActiveRecord validator for any email field that you would use with effective_email or otherwise
2
+ #
3
+ # validates :email, email: true
4
+
5
+ class EmailValidator < ActiveModel::EachValidator
6
+ PATTERN = /\A.+@.+\..+\Z/
7
+
8
+ def validate_each(record, attribute, value)
9
+ if value.present?
10
+ record.errors.add(attribute, 'is invalid') unless PATTERN =~ value
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # An ActiveRecord validator for any url field that you would use with effective_url or otherwise
2
+ #
3
+ # validates :website, url: true
4
+
5
+ class UrlValidator < ActiveModel::EachValidator
6
+ PATTERN = /\Ahttps?:\/\/\w+.+\Z/
7
+
8
+ def validate_each(record, attribute, value)
9
+ if value.present?
10
+ record.errors.add(attribute, 'is invalid') unless PATTERN =~ value
11
+ end
12
+ end
13
+ end
@@ -2,7 +2,12 @@ module EffectiveResources
2
2
  class Engine < ::Rails::Engine
3
3
  engine_name 'effective_resources'
4
4
 
5
- config.autoload_paths += Dir["#{config.root}/lib/", "#{config.root}/jobs/", "#{config.root}/app/controllers/concerns/effective/"]
5
+ config.autoload_paths += Dir[
6
+ "#{config.root}/lib/",
7
+ "#{config.root}/jobs/",
8
+ "#{config.root}/app/models/validators/",
9
+ "#{config.root}/app/controllers/concerns/effective/"
10
+ ]
6
11
 
7
12
  # Set up our default configuration options.
8
13
  initializer 'effective_resources.defaults', before: :load_config_initializers do |app|
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.3.12'.freeze
2
+ VERSION = '1.3.13'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.12
4
+ version: 1.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-23 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -71,6 +71,8 @@ files:
71
71
  - app/models/effective/resources/paths.rb
72
72
  - app/models/effective/resources/relation.rb
73
73
  - app/models/effective/resources/sql.rb
74
+ - app/models/validators/email_validator.rb
75
+ - app/models/validators/url_validator.rb
74
76
  - app/views/application/_flash.html.haml
75
77
  - app/views/application/create.js.erb
76
78
  - app/views/application/destroy.js.erb