validates 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in validates.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/validates.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "validates/version"
2
+ require "validates/email_validator"
3
+ require "validates/slug_validator"
4
+ require "validates/url_validator"
5
+
@@ -0,0 +1,8 @@
1
+ class EmailValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ return if value.blank?
4
+ unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
5
+ record.errors.add(attribute, :email, options.merge(:value => value))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ class SlugValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ unless value =~ /^[\w-]+$/i
4
+ record.errors.add(attribute, :slug, options.merge(:value => value))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class UrlValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ unless value =~ URI::regexp(%w(http https))
4
+ record.errors.add(attribute, :url, options.merge(:value => value))
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Validates
2
+ VERSION = "0.0.1"
3
+ end
data/validates.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "validates/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "validates"
7
+ s.version = Validates::VERSION
8
+ s.authors = ["Mikhail Stolbov"]
9
+ s.email = ["mstolbov@gmail.com"]
10
+ s.homepage = "https://github.com/kaize/validates"
11
+ s.summary = "Collection of simple validators for Rails 3"
12
+ s.description = "Email, Slug, Url validators for Rails 3"
13
+
14
+ s.rubyforge_project = "validates"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "activemodel", [">= 3.0.0"]
24
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: validates
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Mikhail Stolbov
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-17 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activemodel
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ version: 3.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Email, Slug, Url validators for Rails 3
37
+ email:
38
+ - mstolbov@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - .gitignore
47
+ - Gemfile
48
+ - Rakefile
49
+ - lib/validates.rb
50
+ - lib/validates/email_validator.rb
51
+ - lib/validates/slug_validator.rb
52
+ - lib/validates/url_validator.rb
53
+ - lib/validates/version.rb
54
+ - validates.gemspec
55
+ homepage: https://github.com/kaize/validates
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project: validates
84
+ rubygems_version: 1.8.10
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Collection of simple validators for Rails 3
88
+ test_files: []
89
+