glib-web 0.4.44 → 0.4.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/validators/email_validator.rb +7 -0
- data/app/validators/url_validator.rb +20 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 727dd053b29d3f7cd0240609838c9a4003cdf5273b070087eeeffc2245a3c57b
|
4
|
+
data.tar.gz: b8c076c6d5f32bbc2a71d945c13ecf5b71e1d2eec23a3abea48aff16f797ba83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b40d4670a950a84bd3f9e65ac0b0783b9d50781e2b493d503b1c8fb2e0290ba1f439cd95b144d583cfb8ced20d1d89842dc7c8d12d1d2056a9429449d9960c0
|
7
|
+
data.tar.gz: c6228d6a4f503b6f8d51c5015b8cc80cef258aacecd9cff99e09fc9f4d85dafb434c0930ad8f21c7475fbc67732319fcabfe2baa2dc552ea864a81da1593e844
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class UrlValidator < ActiveModel::EachValidator
|
2
|
+
def validate_each(record, attribute, value)
|
3
|
+
schemes = ['https', 'http']
|
4
|
+
|
5
|
+
begin
|
6
|
+
uri = URI.parse(value)
|
7
|
+
host = uri && uri.host
|
8
|
+
scheme = uri && uri.scheme
|
9
|
+
|
10
|
+
valid_scheme = host && scheme && schemes.include?(scheme)
|
11
|
+
valid_raw_url = scheme && value.match?(URI::regexp([scheme]))
|
12
|
+
|
13
|
+
unless valid_raw_url && valid_scheme
|
14
|
+
record.errors.add(attribute, :invalid)
|
15
|
+
end
|
16
|
+
rescue URI::InvalidURIError
|
17
|
+
record.errors.add(attribute, :invalid)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glib-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -101,6 +101,8 @@ files:
|
|
101
101
|
- app/models/glib/dynamic_text_record.rb
|
102
102
|
- app/models/glib/text.rb
|
103
103
|
- app/policies/glib/application_policy.rb
|
104
|
+
- app/validators/email_validator.rb
|
105
|
+
- app/validators/url_validator.rb
|
104
106
|
- app/views/app/views/json_ui/vue/renderer.html.erb
|
105
107
|
- app/views/json_ui/garage/_nav_menu.json.jbuilder
|
106
108
|
- app/views/json_ui/garage/actions/_dialogs.json.jbuilder
|