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.3.0
to
0.3.1
+31
lib/validation/rule/uri.rb
module Validation
module Rule
class URI
def initialize(parts=[:host])
@required_parts = parts
end
def error_key
:uri
end
def params
{:required_elements => @required_parts}
end
def valid_value?(uri_string)
begin
uri = URI(uri_string)
@required_parts.each do |part|
if uri.send(part).nil? || uri.send(part).empty?
return false
end
end
true
rescue ::URI::InvalidURIError => e
return false
end
end
end
end
end
+12
-1

@@ -56,4 +56,15 @@ module Validation

valid = true
all_rules = {}
rules.each_pair do |field, rules|
if self.instance_of?(Validation::Validator)
# use the normal instance variable
all_rules = self.rules
elsif self.is_a?(Validation::Validator) # inherited "stand-alone" validator
# in this case the rules have been defined in the class instance
# variable '@rules' since they were defined during the class definition
all_rules = self.class.rules
end
all_rules.each_pair do |field, rules|
if ! @obj.respond_to?(field)

@@ -60,0 +71,0 @@ raise InvalidKey

+1
-1
module Validation
VERSION = '0.3.0'
VERSION = '0.3.1'
end