Sha256: b7f38ea0af2659c3a125e2a188df7777d0dc92a01e57dd30b955459c6eac3c09
Contents?: true
Size: 747 Bytes
Versions: 2
Compression:
Stored size: 747 Bytes
Contents
require "shoulda-matchers" module Shoulda module Matchers module ActiveModel def require_a_valid_subnet(attribute = :value) SubnetMatcher.new(attribute) end class SubnetMatcher < ValidationMatcher def initialize(attribute) @attribute = attribute end def description "require #{@attribute} to be a valid subnet" end def matches?(subject) super(subject) disallows_invalid_value and allows_valid_value end private def disallows_invalid_value disallows_value_of("10.0.0") end def allows_valid_value allows_value_of("10.10.10.1/28") end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validates_host-0.3.1 | lib/validates_host/shoulda-matchers/subnet_matcher.rb |
validates_host-0.3.0 | lib/validates_host/shoulda-matchers/subnet_matcher.rb |