
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
This is a ActiveModel validators for domains (including TLDs), ip addresses and email addresses.
gem install validator
In your models, the gem provides new validators like :domain, :ip_address or :email
class Model < ActiveRecord::Base
validates :domain_name, :domain => true
validates :ip, :ip_address => true
validates :email_address, :email => true
end
# validate domain name by full length, label length, TLD existing
validates :domain_name, :domain => true
validates :domain_name, :domain => { :message => 'custom message' }
# custom full domain and label length
validates :domain_name, :domain => { :length => 200, :label_length => 60 }
# skip TLD validation
validates :domain_name, :domain => { :check_tld => false }
# validate ip address
validates :ip, :ip_address => true
# ip address allowed with prefix
validates :ip, :ip_address => { :allow_prefix => true }
# allows only IPv4
validates :ip, :ip_address => { :only => :ipv4 }
# allows only IPv6
validates :ip, :ip_address => { :only => :ipv6 }
validates :ip, :ip_address => { :message => "custom message" }
validates :email_address, :email => true
validates :email_address, :email => { :message => 'custom message' }
# custom local part, full domain and label length of email address
validates :email_address, :email => { :local_length => 60, :domain => { :length => 200, :label_length => 60 }}
To customize error message, you can use { :message => "your custom message" } or simple use Rails localization en.yml file, for instance:
en:
errors:
messages:
domain:
length: "your custom length error message"
ip_address:
invalid:
general: "your custom invalid ip address error message"
activemodel:
errors:
messages:
domain:
invalid: "custom error message only for activemodel"
models:
your_model:
domain:
invalid: "custom error message for YourDomain model"
Copyright (c) 2011 Vitaliy Nahaylo. See LICENSE for details.
FAQs
Unknown package
We found that validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.