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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 030a9151bd57835e2fb619e6217b6bfe6810a36a83576708f5123e7f3bf94344
|
4
|
+
data.tar.gz: d0f5871010a0cf031259f9faa87f5dcfcfae5b20f9f46f01dd7443f61df24c56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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[
|
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|
|
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.
|
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-
|
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
|