Project

kangal

0.01
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Kangal brings you a nice set of custom validators for Rails 4.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.3
>= 0
>= 0

Runtime

 Project Readme

Kangal

Code Climate Dependency Status Build Status

Requirements

Before generating your application, you will need:

  • Ruby ~> 2.0
  • Rails ~> 4.0

Usage

In your Gemfile

gem 'kangal'

Email Validator

require 'kangal'
class User
  include ActiveModel::Validations
  attr_accessor :email

  # Email validator
  validates :email, presence: :true, email: :true
end


p = User.new
p.email = "info@lab2023.com"
p.valid? # => true

p.email = "info@lab"
p.valid? # => false

p.email = "Onur Ozgur <info@lab2023.com>"
p.valid? # => false

Subdomain Validator

require 'kangal'
class User
  include ActiveModel::Validations
  attr_accessor :subdomain

  # Subdomain validator
  validates  :subdomain, subdomain: true

  # Or
  validates  :subdomain, subdomain: { :reserved => %w(foo bar) }
end


p = User.new
p.subdomain = "www"
p.valid? # => false

p.subdomain = "https"
p.valid? # => false

p.subdomain = "-lab2023"
p.valid? # => false

p.subdomain = "-lab2023-"
p.valid? # => false

p.subdomain = "foo"
p.valid? # => false

p.subdomain = "lab2023"
p.valid? # => true

Default reserved names: www, ftp, mail, pop, smtp, admin, ssl, sftp, http, https

Turkish Government Identity Number Validator

require 'kangal'
class User
  include ActiveModel::Validations
  attr_accessor :identity

  # Identity Number validator
  validates :identity, presence: :true, identity_number: :true
end

p = User.new
p.identity = "44234234"
p.valid? # => false

p = User.new
p.identity = "02343214582"
p.valid? # => false

p = User.new
p.identity = "83317527040" # (this isn't a real identity number)
p.valid? # => true

Turkish Government Tax Number Validator

require 'kangal'
class User
  include ActiveModel::Validations
  attr_accessor :tax_number

  # Identity Number validator
  validates :tax_number, presence: :true, tcvkn: :true
end

p = User.new
p.tax_number = "44234234"
p.valid? # => false

p = User.new
p.tax_number = "02343214582"
p.valid? # => false

p = User.new
p.tax_number = "6120069217" # (this isn't a real tax number)
p.valid? # => true

IP Validator

require 'kangal'
class Server
  include ActiveModel::Validations
  attr_accessor :ip

  # Ip validator
  validates :ip, presence: :true, ip: :true
end

p = Server.new
p.ip = "10.10.10.256"
p.valid? # => false

p = Server.new
p.ip = "2222.22.22.22"
p.valid? # => false

p = Server.new
p.ip = "255.255.255.255"
p.valid? # => true

p = Server.new
p.ip = "132.254.111.10"
p.valid? # => true

Bugs and Feedback

If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.

http://github.com/lab2023/kangal

Contributing

Kangal uses TomDoc, rDoc and SemVer, and takes it seriously.

Once you've made your great commits:

  1. Fork Template
  2. Create a topic branch - git checkout -b my_branch
  3. Push to your branch - git push origin my_branch
  4. Create a Pull Request from your branch
  5. That's it!

Credits

lab2023

License

Copyright 2014 lab2023 - information technologies