rails-alpha_numeric_validator 0.1.1 → 0.1.2
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
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9dfcd87164ee13652f1d3d12b2705d46ef47deb1
|
4
|
+
data.tar.gz: ce8e3a1fde50fe29bb4d67f58edda2fcef177110
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2cbd90a70ecc2054c438b545cf2e76f91dc80f692c4ccf72a029b4cda2c7637c3d89a74e6ff988299591522ce0d14f3e33e0926f78699c3856277a1afe99d8d7
|
7
|
+
data.tar.gz: 15c2637d07c9516a6610470a19e91ce1c6b5098f6a5395f49a9f0157a75d7e3ec0f9b56d74dc03252f2dbb8d93fcc3f4c0afa509780245bd0508441eaa612588
|
@@ -8,7 +8,7 @@ class AlphaNumericValidator < ActiveModel::EachValidator
|
|
8
8
|
default: /(?:[[:alpha:]]|[[:digit:]])+/,
|
9
9
|
:true => /(?:[[:graph:]])+/,
|
10
10
|
limited: /(?:[[:alpha:]]|[[:digit:]]|[_:\+\.\?,\-!'\/#])+/, # ' vim-color-syntax hack
|
11
|
-
dns: /(?:[[:alpha:]]|[[:digit:]]
|
11
|
+
dns: /(?:[[:alpha:]]|[[:digit:]]|[\.\-])+/,
|
12
12
|
fqdn: /(?:[[:alpha:]]|[[:digit:]]|-|\.)+/}
|
13
13
|
|
14
14
|
WHITESPACE_EXCEPTIONS = [:dns, :fqdn]
|
@@ -20,7 +20,6 @@ class AlphaNumericValidator < ActiveModel::EachValidator
|
|
20
20
|
# validates :attr1, alpha_numeric: true
|
21
21
|
# validates :attr2, alpha_numeric: {punctuation: true}
|
22
22
|
# validates :attr3, alpha_numeric: {punctuation: :limited}
|
23
|
-
# validates :attr4, alpha_numeric: {allow_nil: false, allow_blank: false}
|
24
23
|
# validates :attr4, alpha_numeric: {allow_whitespace: true}
|
25
24
|
# validates :attr4, alpha_numeric: {dns: true}
|
26
25
|
# end
|
@@ -68,8 +67,6 @@ class AlphaNumericValidator < ActiveModel::EachValidator
|
|
68
67
|
# TODO: support international DNS
|
69
68
|
|
70
69
|
def is_valid_string?
|
71
|
-
return true if @options[:allow_nil] && !@string
|
72
|
-
return false if !@options[:allow_blank] && @string.blank?
|
73
70
|
return false if !@options[:allow_whitespace] && has_whitespace?
|
74
71
|
re = PUNCTUATION_REGEXP[@options[:punctuation].to_s.to_sym]
|
75
72
|
@string.to_s.gsub(re, "").blank?
|
@@ -25,7 +25,7 @@ class Model < ActiveRecord::Base
|
|
25
25
|
attr_accessible :name, :organization, :favorite_quote, :server_name, :website, :id_code
|
26
26
|
validates :name, :alpha_numeric => true
|
27
27
|
validates :organization, :alpha_numeric => {punctuation: :limited}
|
28
|
-
validates :favorite_quote, :alpha_numeric => {punctuation: true
|
28
|
+
validates :favorite_quote, :alpha_numeric => {punctuation: true}
|
29
29
|
validates :server_name, :alpha_numeric => {punctuation: :dns}
|
30
30
|
validates :website, :alpha_numeric => {punctuation: :fqdn}
|
31
31
|
validates :id_code, :alpha_numeric => {allow_whitespace: false}
|
@@ -50,7 +50,7 @@ class AlphaNumericValidatorTest < Test::Unit::TestCase
|
|
50
50
|
@model = Model.new(:name => 'Paul Belt', :organization => 'Hello Corp.', :favorite_quote => 'Hello world!',
|
51
51
|
:server_name => 'hello-world', :website => 'hello-world.example.com', :id_code => 'abc123')
|
52
52
|
assert @model.valid?
|
53
|
-
validations = {name: [['Bob1 Jones2', 'abcdef'], ['Bob# Jones?', '!@#$!@']],
|
53
|
+
validations = {name: [['Bob1 Jones2', 'abcdef', '', nil], ['Bob# Jones?', '!@#$!@']],
|
54
54
|
organization: [["McDonald's", 'Yahoo!', 'ABC-DEF + GHI', 'with: colons'], %w(A@B XYZ~3)],
|
55
55
|
favorite_quote: [['This$is=a& good*string', '~!@#$%^&*()'], %W(Hello\x00)],
|
56
56
|
server_name: [%w(hello1 abcdef), ['hello world', 'hello~world']],
|
metadata
CHANGED
@@ -1,112 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-alpha_numeric_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.1
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Paul Belt
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
17
|
- - ~>
|
19
18
|
- !ruby/object:Gem::Version
|
20
19
|
version: 3.2.13
|
21
|
-
|
22
|
-
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.13
|
27
|
-
none: false
|
28
|
-
prerelease: false
|
29
|
-
type: :runtime
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
33
30
|
requirements:
|
34
31
|
- - ~>
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '1.3'
|
37
|
-
|
38
|
-
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
37
|
requirements:
|
40
38
|
- - ~>
|
41
39
|
- !ruby/object:Gem::Version
|
42
40
|
version: '1.3'
|
43
|
-
none: false
|
44
|
-
prerelease: false
|
45
|
-
type: :development
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
|
-
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
49
44
|
requirements:
|
50
|
-
- -
|
45
|
+
- - '>='
|
51
46
|
- !ruby/object:Gem::Version
|
52
47
|
version: '0'
|
53
|
-
|
54
|
-
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
51
|
requirements:
|
56
|
-
- -
|
52
|
+
- - '>='
|
57
53
|
- !ruby/object:Gem::Version
|
58
54
|
version: '0'
|
59
|
-
none: false
|
60
|
-
prerelease: false
|
61
|
-
type: :development
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: sqlite3
|
64
|
-
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
65
58
|
requirements:
|
66
|
-
- -
|
59
|
+
- - '>='
|
67
60
|
- !ruby/object:Gem::Version
|
68
61
|
version: 1.3.7
|
69
|
-
|
70
|
-
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
|
-
- -
|
66
|
+
- - '>='
|
73
67
|
- !ruby/object:Gem::Version
|
74
68
|
version: 1.3.7
|
75
|
-
none: false
|
76
|
-
prerelease: false
|
77
|
-
type: :development
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: debugger
|
80
|
-
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
81
72
|
requirements:
|
82
|
-
- -
|
73
|
+
- - '>='
|
83
74
|
- !ruby/object:Gem::Version
|
84
75
|
version: 1.5.0
|
85
|
-
|
86
|
-
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
79
|
requirements:
|
88
|
-
- -
|
80
|
+
- - '>='
|
89
81
|
- !ruby/object:Gem::Version
|
90
82
|
version: 1.5.0
|
91
|
-
none: false
|
92
|
-
prerelease: false
|
93
|
-
type: :development
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rspec
|
96
|
-
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
97
86
|
requirements:
|
98
|
-
- -
|
87
|
+
- - '>='
|
99
88
|
- !ruby/object:Gem::Version
|
100
89
|
version: 2.13.0
|
101
|
-
|
102
|
-
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
103
93
|
requirements:
|
104
|
-
- -
|
94
|
+
- - '>='
|
105
95
|
- !ruby/object:Gem::Version
|
106
96
|
version: 2.13.0
|
107
|
-
none: false
|
108
|
-
prerelease: false
|
109
|
-
type: :development
|
110
97
|
description: validate model attributes follow specific guidelines e.g. only printable
|
111
98
|
characters, no whitespace, etc
|
112
99
|
email:
|
@@ -132,25 +119,24 @@ files:
|
|
132
119
|
homepage: https://github.com/belt/rails-alpha_numeric_validator
|
133
120
|
licenses:
|
134
121
|
- MIT
|
122
|
+
metadata: {}
|
135
123
|
post_install_message:
|
136
124
|
rdoc_options: []
|
137
125
|
require_paths:
|
138
126
|
- lib
|
139
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
128
|
requirements:
|
141
|
-
- -
|
129
|
+
- - '>='
|
142
130
|
- !ruby/object:Gem::Version
|
143
131
|
version: 1.9.2
|
144
|
-
none: false
|
145
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
133
|
requirements:
|
147
|
-
- -
|
134
|
+
- - '>='
|
148
135
|
- !ruby/object:Gem::Version
|
149
136
|
version: '0'
|
150
|
-
none: false
|
151
137
|
requirements: []
|
152
138
|
rubyforge_project:
|
153
|
-
rubygems_version:
|
139
|
+
rubygems_version: 2.0.3
|
154
140
|
signing_key:
|
155
141
|
specification_version: 3
|
156
142
|
summary: validate model attributes follow specific guidelines e.g. only printable
|