Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

valid

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valid - npm Package Compare versions

Comparing version
0.2.1
to
0.3.0
+39
lib/validation/rule/phone.rb
module Validation
module Rule
# Phone rule
class Phone
# params can be any of the following:
#
# - :format - the phone number format
#
# Example:
#
# {:format => :america}
def initialize(params = {:format => :america})
@params = params
end
# returns the params given in the constructor
def params
@params
end
# determines if value is valid according to the constructor params
def valid_value?(value)
send(@params[:format], value)
end
def error_key
:phone
end
protected
def america(value)
digits = value.gsub(/\D/, '').split(//)
digits.length == 10 || digits.length == 11
end
end
end
end
+1
-1
module Validation
VERSION = '0.2.1'
VERSION = '0.3.0'
end
# Validator
[![Build Status](https://secure.travis-ci.org/zombor/Validator.png)](http://travis-ci.org/zombor/Validator)
Validator is a simple ruby validation class. You don't use it directly inside your classes like just about every other ruby validation class out there. I chose to implement it in this way so I didn't automatically pollute the namespace of the objects I wanted to validate.

@@ -4,0 +6,0 @@