lite-validators 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.fasterer.yml +19 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +4 -0
  5. data/.rubocop.yml +31 -0
  6. data/.travis.yml +24 -0
  7. data/CHANGELOG.md +11 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +6 -0
  10. data/Gemfile.lock +128 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +88 -0
  13. data/Rakefile +8 -0
  14. data/_config.yml +1 -0
  15. data/bin/console +15 -0
  16. data/bin/setup +8 -0
  17. data/config/locales/en.yml +23 -0
  18. data/docs/ALPHA.md +29 -0
  19. data/docs/ALPHA_NUMERIC.md +29 -0
  20. data/docs/BASE64.md +18 -0
  21. data/docs/BOOLEAN.md +19 -0
  22. data/docs/COMPARE.md +30 -0
  23. data/docs/COORDINATE.md +27 -0
  24. data/docs/CREDIT_CARD.md +29 -0
  25. data/docs/CSV.md +44 -0
  26. data/docs/CURRENCY.md +18 -0
  27. data/docs/CUSIP.md +20 -0
  28. data/docs/EMAIL.md +26 -0
  29. data/docs/FILE_CONTENT_TYPE.md +26 -0
  30. data/docs/FILE_EXTENSION.md +25 -0
  31. data/docs/FILE_SIZE.md +38 -0
  32. data/docs/HEX.md +18 -0
  33. data/docs/IMEI.md +20 -0
  34. data/docs/IP_ADDRESS.md +26 -0
  35. data/docs/ISBN.md +18 -0
  36. data/docs/ISIN.md +20 -0
  37. data/docs/MAC_ADDRESS.md +21 -0
  38. data/docs/NAME.md +18 -0
  39. data/docs/PASSWORD.md +26 -0
  40. data/docs/PHONE_NUMBER.md +18 -0
  41. data/docs/SEDOL.md +20 -0
  42. data/docs/SLUG.md +18 -0
  43. data/docs/SSN.md +18 -0
  44. data/docs/TIME_ZONE.md +17 -0
  45. data/docs/TYPE.md +28 -0
  46. data/docs/URL.md +28 -0
  47. data/docs/USERNAME.md +18 -0
  48. data/docs/UUID.md +28 -0
  49. data/lib/lite/validators/alpha_numeric_validator.rb +11 -0
  50. data/lib/lite/validators/alpha_validator.rb +34 -0
  51. data/lib/lite/validators/base64_validator.rb +9 -0
  52. data/lib/lite/validators/base_validator.rb +54 -0
  53. data/lib/lite/validators/boolean_validator.rb +15 -0
  54. data/lib/lite/validators/compare_validator.rb +41 -0
  55. data/lib/lite/validators/coordinate_validator.rb +37 -0
  56. data/lib/lite/validators/credit_card_validator.rb +144 -0
  57. data/lib/lite/validators/csv_validator.rb +73 -0
  58. data/lib/lite/validators/currency_validator.rb +7 -0
  59. data/lib/lite/validators/cusip_validator.rb +27 -0
  60. data/lib/lite/validators/email_validator.rb +19 -0
  61. data/lib/lite/validators/file_content_type_validator.rb +38 -0
  62. data/lib/lite/validators/file_extension_validator.rb +41 -0
  63. data/lib/lite/validators/file_size_validator.rb +75 -0
  64. data/lib/lite/validators/hex_validator.rb +7 -0
  65. data/lib/lite/validators/imei_validator.rb +27 -0
  66. data/lib/lite/validators/ip_address_validator.rb +39 -0
  67. data/lib/lite/validators/isbn_validator.rb +16 -0
  68. data/lib/lite/validators/isin_validator.rb +36 -0
  69. data/lib/lite/validators/mac_address_validator.rb +18 -0
  70. data/lib/lite/validators/name_validator.rb +7 -0
  71. data/lib/lite/validators/password_validator.rb +29 -0
  72. data/lib/lite/validators/phone_number_validator.rb +7 -0
  73. data/lib/lite/validators/sedol_validator.rb +23 -0
  74. data/lib/lite/validators/slug_validator.rb +7 -0
  75. data/lib/lite/validators/ssn_validator.rb +7 -0
  76. data/lib/lite/validators/time_zone_validator.rb +13 -0
  77. data/lib/lite/validators/type_validator.rb +41 -0
  78. data/lib/lite/validators/url_validator.rb +61 -0
  79. data/lib/lite/validators/username_validator.rb +7 -0
  80. data/lib/lite/validators/uuid_validator.rb +37 -0
  81. data/lib/lite/validators/version.rb +9 -0
  82. data/lib/lite/validators.rb +12 -0
  83. data/lite-validators.gemspec +51 -0
  84. metadata +265 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 01d223e74a65a8ce210c64227246eee8aca7df6d9be7229e4d7305959a716b96
4
+ data.tar.gz: 63c6a6b94991628b2a83fc8892bda9c2d5df8b0c087850c9e8a7bea7aa949400
5
+ SHA512:
6
+ metadata.gz: ce3c9c1d596050bbe4f9fcbe05f2d402a9de076e195bd854a41ba016930f3d3c784eb9f1ed17694b462e21b45e374c0c9f4c90084c1a759677f9fe422adb1e67
7
+ data.tar.gz: 11fb1e3bf10d0717696792f3e242832db5b0eaf9a4cbd8b0109c01d21535d06790e7f6e0aa510ce3166e022379ab8c4daaf659424a1573b50b787226c168d010
data/.fasterer.yml ADDED
@@ -0,0 +1,19 @@
1
+ speedups:
2
+ block_vs_symbol_to_proc: true
3
+ each_with_index_vs_while: false
4
+ fetch_with_argument_vs_block: true
5
+ for_loop_vs_each: true
6
+ getter_vs_attr_reader: true
7
+ gsub_vs_tr: true
8
+ hash_merge_bang_vs_hash_brackets: true
9
+ keys_each_vs_each_key: true
10
+ map_flatten_vs_flat_map: true
11
+ module_eval: true
12
+ proc_call_vs_yield: true
13
+ rescue_vs_respond_to: true
14
+ reverse_each_vs_reverse_each: true
15
+ select_first_vs_detect: true
16
+ select_last_vs_reverse_detect: true
17
+ setter_vs_attr_writer: true
18
+ shuffle_first_vs_sample: true
19
+ sort_vs_sort_by: true
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --backtrace
2
+ --color
3
+ --format progress
4
+ --order random
data/.rubocop.yml ADDED
@@ -0,0 +1,31 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+ AllCops:
5
+ TargetRubyVersion: 2.6
6
+ DisplayCopNames: true
7
+ DisplayStyleGuide: true
8
+ LineLength:
9
+ Max: 100
10
+ Layout/EmptyLinesAroundBlockBody:
11
+ Exclude:
12
+ - 'spec/**/**/*'
13
+ Layout/EmptyLinesAroundClassBody:
14
+ EnforcedStyle: empty_lines_except_namespace
15
+ Layout/EmptyLinesAroundModuleBody:
16
+ EnforcedStyle: empty_lines_except_namespace
17
+ Metrics/BlockLength:
18
+ Exclude:
19
+ - 'spec/**/**/*'
20
+ - '*.gemspec'
21
+ Metrics/ClassLength:
22
+ Exclude:
23
+ - 'lib/lite/validators/credit_card_validator.rb'
24
+ RSpec/ExampleLength:
25
+ Enabled: false
26
+ RSpec/MultipleExpectations:
27
+ Enabled: false
28
+ Style/Documentation:
29
+ Enabled: false
30
+ Style/ExpandPathArguments:
31
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.5
6
+ - 2.6
7
+ - ruby-head
8
+ matrix:
9
+ fast_finish: true
10
+ allow_failures:
11
+ - rvm: ruby-head
12
+ before_install:
13
+ - gem update --system
14
+ - gem install bundler
15
+ install:
16
+ - bundle install --jobs=3 --retry=3
17
+ script:
18
+ - bundle exec rspec
19
+ - bundle exec rubocop
20
+ - bundle exec fasterer
21
+ notifications:
22
+ email: false
23
+ slack:
24
+ secure: ymrsJTXpcQPEf9MmDKJHIjVo4eLkpuO/Oudt+4uHjqbOukfL4pMbER5FBFEgIqFKR9dM10cCwd5wJf73187CeWQpvm+2Ih2xtenKI/8z5e6iSNvB4+NZiWeIjRmTErAi2qk74m5nOMQ2nGlaKZLvw9VVD0rAQhhem7ec+Ui+ovPH97pNUlDxOgmKUDTtzeaP/jnN0c6kjksAalabg4xnSUhDmImfrRiPux+bTum142bnTx4ahiFQ7tYEi6A9Z4W5IHCgu+YwpT8Hz6OLPWm0BDOLA5sbjgcz2l0SFmwebcPRknDUeBT9+NTZOrhxRWvmJ/TR69hihhZj5k8WQ9wZKCvfl9U7bRFBQdQpU0BD3+cCTnE+sMRzcBaNOp7oXwHpZzeStcZGq0J2qF8lCvqFp2AgpAAnJ/GyC29rLFpWwwMsigFBgjFJnGrv2ZbiKHHbspXRJnGZY79kySfM5CeoY/q74+Jn12712636n2YmpXDglPqhumm6pJ8NvyoMRphRuIt4B9Ar5P1Q0u4QoEdvaCFB9HXR/nOmt/LRskSpCoK7Z0HZJ14YGu58kVR3guviI3ah6bVAzJ1PZZVIn3xUqTApA6csV3uoVh0ZiI8nF+gWbSsFofphRBhAM584D97toT7L5UctZ+KA/oD0Tknc6qXhOo2OLemjvYNW+Cl1g1k=
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [1.0.0] - 2019-06-26
10
+ ### Added
11
+ - Initial project version
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at j.gomez@drexed.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in lite-validators.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,128 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lite-validators (1.0.0)
5
+ activemodel
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (5.2.3)
11
+ actionview (= 5.2.3)
12
+ activesupport (= 5.2.3)
13
+ rack (~> 2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.2.3)
18
+ activesupport (= 5.2.3)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activemodel (5.2.3)
24
+ activesupport (= 5.2.3)
25
+ activesupport (5.2.3)
26
+ concurrent-ruby (~> 1.0, >= 1.0.2)
27
+ i18n (>= 0.7, < 2)
28
+ minitest (~> 5.1)
29
+ tzinfo (~> 1.1)
30
+ ast (2.4.0)
31
+ builder (3.2.3)
32
+ colorize (0.8.1)
33
+ concurrent-ruby (1.1.5)
34
+ crass (1.0.4)
35
+ diff-lcs (1.3)
36
+ erubi (1.8.0)
37
+ fasterer (0.5.1)
38
+ colorize (~> 0.7)
39
+ ruby_parser (>= 3.13.0)
40
+ i18n (1.6.0)
41
+ concurrent-ruby (~> 1.0)
42
+ jaro_winkler (1.5.3)
43
+ loofah (2.2.3)
44
+ crass (~> 1.0.2)
45
+ nokogiri (>= 1.5.9)
46
+ method_source (0.9.2)
47
+ mini_portile2 (2.4.0)
48
+ minitest (5.11.3)
49
+ nokogiri (1.10.3)
50
+ mini_portile2 (~> 2.4.0)
51
+ parallel (1.17.0)
52
+ parser (2.6.3.0)
53
+ ast (~> 2.4.0)
54
+ rack (2.0.7)
55
+ rack-test (1.1.0)
56
+ rack (>= 1.0, < 3)
57
+ rails-dom-testing (2.0.3)
58
+ activesupport (>= 4.2.0)
59
+ nokogiri (>= 1.6)
60
+ rails-html-sanitizer (1.0.4)
61
+ loofah (~> 2.2, >= 2.2.2)
62
+ railties (5.2.3)
63
+ actionpack (= 5.2.3)
64
+ activesupport (= 5.2.3)
65
+ method_source
66
+ rake (>= 0.8.7)
67
+ thor (>= 0.19.0, < 2.0)
68
+ rainbow (3.0.0)
69
+ rake (12.3.2)
70
+ rspec (3.8.0)
71
+ rspec-core (~> 3.8.0)
72
+ rspec-expectations (~> 3.8.0)
73
+ rspec-mocks (~> 3.8.0)
74
+ rspec-core (3.8.2)
75
+ rspec-support (~> 3.8.0)
76
+ rspec-expectations (3.8.4)
77
+ diff-lcs (>= 1.2.0, < 2.0)
78
+ rspec-support (~> 3.8.0)
79
+ rspec-mocks (3.8.1)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.8.0)
82
+ rspec-rails (3.8.2)
83
+ actionpack (>= 3.0)
84
+ activesupport (>= 3.0)
85
+ railties (>= 3.0)
86
+ rspec-core (~> 3.8.0)
87
+ rspec-expectations (~> 3.8.0)
88
+ rspec-mocks (~> 3.8.0)
89
+ rspec-support (~> 3.8.0)
90
+ rspec-support (3.8.2)
91
+ rubocop (0.72.0)
92
+ jaro_winkler (~> 1.5.1)
93
+ parallel (~> 1.10)
94
+ parser (>= 2.6)
95
+ rainbow (>= 2.2.2, < 4.0)
96
+ ruby-progressbar (~> 1.7)
97
+ unicode-display_width (>= 1.4.0, < 1.7)
98
+ rubocop-performance (1.4.0)
99
+ rubocop (>= 0.71.0)
100
+ rubocop-rspec (1.33.0)
101
+ rubocop (>= 0.60.0)
102
+ ruby-progressbar (1.10.1)
103
+ ruby_parser (3.13.1)
104
+ sexp_processor (~> 4.9)
105
+ sexp_processor (4.12.1)
106
+ thor (0.20.3)
107
+ thread_safe (0.3.6)
108
+ tzinfo (1.2.5)
109
+ thread_safe (~> 0.1)
110
+ unicode-display_width (1.6.0)
111
+
112
+ PLATFORMS
113
+ ruby
114
+
115
+ DEPENDENCIES
116
+ actionpack
117
+ bundler
118
+ fasterer
119
+ lite-validators!
120
+ rake
121
+ rspec
122
+ rspec-rails
123
+ rubocop
124
+ rubocop-performance
125
+ rubocop-rspec
126
+
127
+ BUNDLED WITH
128
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Juan Gomez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # Lite::Validators
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/lite-validators.svg)](http://badge.fury.io/rb/lite-validators)
4
+ [![Build Status](https://travis-ci.org/drexed/lite-validators.svg?branch=master)](https://travis-ci.org/drexed/lite-validators)
5
+
6
+ Lite::Validators is a collection of validators useful for any Rails application.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'lite-validators'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install lite-validators
23
+
24
+ ## Table of Contents
25
+
26
+ * [Validators](#validators)
27
+ * [3rd-party](#3rd-party)
28
+
29
+ ## Validators
30
+
31
+ * [Alpha](https://github.com/drexed/lite-validators/blob/master/docs/ALPHA.md)
32
+ * [AlphaNumeric](https://github.com/drexed/lite-validators/blob/master/docs/ALPHA_NUMERIC.md)
33
+ * [Base64](https://github.com/drexed/lite-validators/blob/master/docs/BASE64.md)
34
+ * [Boolean](https://github.com/drexed/lite-validators/blob/master/docs/BOOLEAN.md)
35
+ * [Compare](https://github.com/drexed/lite-validators/blob/master/docs/COMPARE.md)
36
+ * [Coordinates](https://github.com/drexed/lite-validators/blob/master/docs/COORDINATE.md)
37
+ * [Credit Card](https://github.com/drexed/lite-validators/blob/master/docs/CREDIT_CARD.md)
38
+ * [Csv](https://github.com/drexed/lite-validators/blob/master/docs/CSV.md)
39
+ * [Currency](https://github.com/drexed/lite-validators/blob/master/docs/CURRENCY.md)
40
+ * [CUSIP](https://github.com/drexed/lite-validators/blob/master/docs/CUSIP.md)
41
+ * [Email](https://github.com/drexed/lite-validators/blob/master/docs/EMAIL.md)
42
+ * [File Content Type](https://github.com/drexed/lite-validators/blob/master/docs/FILE_CONTENT_TYPE.md)
43
+ * [File Extension](https://github.com/drexed/lite-validators/blob/master/docs/FILE_EXTENSION.md)
44
+ * [File Size](https://github.com/drexed/lite-validators/blob/master/docs/FILE_SIZE.md)
45
+ * [HEX](https://github.com/drexed/lite-validators/blob/master/docs/HEX.md)
46
+ * [IMEI](https://github.com/drexed/lite-validators/blob/master/docs/IMEI.md)
47
+ * [IP Address](https://github.com/drexed/lite-validators/blob/master/docs/IP_ADDRESS.md)
48
+ * [ISBN](https://github.com/drexed/lite-validators/blob/master/docs/ISBN.md)
49
+ * [ISIN](https://github.com/drexed/lite-validators/blob/master/docs/ISIN.md)
50
+ * [MAC Address](https://github.com/drexed/lite-validators/blob/master/docs/MAC.md)
51
+ * [Name](https://github.com/drexed/lite-validators/blob/master/docs/NAME.md)
52
+ * [Password](https://github.com/drexed/lite-validators/blob/master/docs/PASSWORD.md)
53
+ * [Phone Number](https://github.com/drexed/lite-validators/blob/master/docs/PHONE_NUMBER.md)
54
+ * [SEDOL](https://github.com/drexed/lite-validators/blob/master/docs/SEDOL.md)
55
+ * [Slug](https://github.com/drexed/lite-validators/blob/master/docs/SLUG.md)
56
+ * [SSN](https://github.com/drexed/lite-validators/blob/master/docs/SSN.md)
57
+ * [Time Zone](https://github.com/drexed/lite-validators/blob/master/docs/TIME_ZONE.md)
58
+ * [Type](https://github.com/drexed/lite-validators/blob/master/docs/TYPE.md)
59
+ * [URL](https://github.com/drexed/lite-validators/blob/master/docs/URL.md)
60
+ * [Username](https://github.com/drexed/lite-validators/blob/master/docs/USERNAME.md)
61
+ * [UUID](https://github.com/drexed/lite-validators/blob/master/docs/UUID.md)
62
+
63
+ ## 3rd-party
64
+
65
+ The following are highly recommended 3rd party validators to supplement your workflow:
66
+
67
+ * **DateTime:** Validates Timeliness - https://github.com/adzap/validates_timeliness
68
+ * **Existence:** Validates Existence - https://github.com/perfectline/validates_existence
69
+ * **Group:** Group Validations - https://github.com/adzap/grouped_validations
70
+ * **Overlap:** Validates Overlap - https://github.com/robinbortlik/validates_overlap
71
+
72
+ ## Development
73
+
74
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
75
+
76
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
77
+
78
+ ## Contributing
79
+
80
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lite-validators. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
81
+
82
+ ## License
83
+
84
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
85
+
86
+ ## Code of Conduct
87
+
88
+ Everyone interacting in the Lite::Validators project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lite-validators/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/_config.yml ADDED
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-leap-day
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'lite/validators'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ csv:
5
+ in: "csv %{dimension} is not between %{min} and %{max}"
6
+ greater_than: "csv %{dimension} is not greater than %{count}"
7
+ greater_than_or_equal_to: "csv %{dimension} is not greater than or equal to %{count}"
8
+ less_than: "csv %{dimension} is not less than %{count}"
9
+ less_than_or_equal_to: "csv %{dimension} is not less than or equal to %{count}"
10
+ equal_to: "csv %{dimension} is not equal to %{count} but should"
11
+ not_equal_to: "csv %{dimension} is equal to %{count} but shouldn't"
12
+ file_size:
13
+ in: "file size is not between %{min} and %{max}"
14
+ greater_than: "file size is not greater than %{count}"
15
+ greater_than_or_equal_to: "file size is not greater than or equal to %{count}"
16
+ less_than: "file size is not less than %{count}"
17
+ less_than_or_equal_to: "file size is not less than or equal to %{count}"
18
+ equal_to: "file size is not equal to %{count} but should"
19
+ not_equal_to: "file size is equal to %{count} but shouldn't"
20
+ url:
21
+ domain: "has an invalid domain"
22
+ root: "has a url path but shouldn't"
23
+ scheme: "has an invalid scheme"
data/docs/ALPHA.md ADDED
@@ -0,0 +1,29 @@
1
+ # Alpha
2
+
3
+ #### Rules
4
+
5
+ ```ruby
6
+ # 1. Pattern
7
+ :any => /^[A-Za-z]+$/
8
+ :lower => /^[a-z]+$/
9
+ :upper => /^[A-Z]+$/
10
+ ```
11
+
12
+ #### Options
13
+
14
+ Option | Type | Available | Default
15
+ --- | --- | --- | ---
16
+ case | symbol | any, lower, upper | any
17
+ allow_space | boolean | true, false | false
18
+
19
+ #### Usage
20
+
21
+ ```ruby
22
+ class User < ActiveRecord::Base
23
+
24
+ validates :input_0, alpha: true
25
+ validates :input_1, alpha: { case: :lower }
26
+ validates :input_2, alpha: { allow_space: true }
27
+
28
+ end
29
+ ```
@@ -0,0 +1,29 @@
1
+ # Alpha numeric
2
+
3
+ #### Rules
4
+
5
+ ```ruby
6
+ # 1. Pattern
7
+ :any => /^[A-Za-z0-9]+$/
8
+ :lower => /^[a-z0-9]+$/
9
+ :upper => /^[A-Z0-9]+$/
10
+ ```
11
+
12
+ #### Options
13
+
14
+ Option | Type | Available | Default
15
+ --- | --- | --- | ---
16
+ case | symbol | any, lower, upper | any
17
+ allow_space | boolean | true, false | false
18
+
19
+ #### Usage
20
+
21
+ ```ruby
22
+ class User < ActiveRecord::Base
23
+
24
+ validates :input_0, alpha_numeric: true
25
+ validates :input_1, alpha_numeric: { case: :lower }
26
+ validates :input_2, alpha_numeric: { allow_space: true }
27
+
28
+ end
29
+ ```
data/docs/BASE64.md ADDED
@@ -0,0 +1,18 @@
1
+ # Base64
2
+
3
+ #### Rules
4
+
5
+ ```ruby
6
+ # 1. Pattern
7
+ /^(?:[A-Za-z0-9+$]{4})*(?:[A-Za-z0-9+$]{2}==|[A-Za-z0-9+$]{3}=|[A-Za-z0-9+$]{4})$/
8
+ ```
9
+
10
+ #### Usage
11
+
12
+ ```ruby
13
+ class User < ActiveRecord::Base
14
+
15
+ validates :input_0, base64: true
16
+
17
+ end
18
+ ```
data/docs/BOOLEAN.md ADDED
@@ -0,0 +1,19 @@
1
+ # Boolean
2
+
3
+ #### Rules
4
+
5
+ ```ruby
6
+ # 1. Pattern
7
+ 'true_values' => [true, 1, '1', 't', 'T', 'true', 'TRUE']
8
+ 'false values' => [false, 0, '0', 'f', 'F', 'false', 'FALSE']
9
+ ```
10
+
11
+ #### Usage
12
+
13
+ ```ruby
14
+ class User < ActiveRecord::Base
15
+
16
+ validates :input_0, boolean: true
17
+
18
+ end
19
+ ```
data/docs/COMPARE.md ADDED
@@ -0,0 +1,30 @@
1
+ # Compare
2
+
3
+ #### Rules
4
+
5
+ ```ruby
6
+ # 1. Check
7
+ :less_than => '<'
8
+ :less_than_or_equal_to => '<='
9
+ :greater_than => '>'
10
+ :greater_than_or_equal_to => '>='
11
+ :equal_to => '=='
12
+ :not_equal_to => '!='
13
+ ```
14
+
15
+ #### Options
16
+
17
+ Option | Type | Available | Default
18
+ --- | --- | --- | ---
19
+ check | symbol | less_than, less_than_or_equal_to, greater_than, greater_than_or_equal_to, equal_to, not_equal_to | equal_to
20
+ to | symbol | |
21
+
22
+ #### Usage
23
+
24
+ ```ruby
25
+ class User < ActiveRecord::Base
26
+
27
+ validates :input_0, equality: { to: :input_1, check: :less_than }
28
+
29
+ end
30
+ ```
@@ -0,0 +1,27 @@
1
+ # Coordinate
2
+
3
+ #### Rules
4
+
5
+ ```ruby
6
+ # 1. Pattern
7
+ :latitude => -90.0..90.0 #=> Value must be a number in this range
8
+ :longitude => -180.0..180.0 #=> Value must be a number in this range
9
+ :pair => [:latitude, :longitude] #=> Array of corresponding range value
10
+ ```
11
+
12
+ #### Options
13
+
14
+ Option | Type | Available | Default
15
+ --- | --- | --- | ---
16
+ boundary | symbol | latitude, longitude, pair | pair
17
+
18
+ #### Usage
19
+
20
+ ```ruby
21
+ class User < ActiveRecord::Base
22
+
23
+ validates :input_0, coordinate: true
24
+ validates :input_1, coordinate: { boundary: :latitude }
25
+
26
+ end
27
+ ```