Sha256: 51fb01647689e61f37f9f4b314a5127daf2eb32ec4aaf87bd1cf272d103407f3

Contents?: true

Size: 391 Bytes

Versions: 6

Compression:

Stored size: 391 Bytes

Contents

module Codebreaker
  module Mixins
    module Validatable
      def validate
        raise NotImplementedError
      end

      def validate_length(value, min, max)
        return if value.instance_of?(String) && value.size >= min && value.size <= max

        raise Codebreaker::Errors::ValidationLengthError, "invalid length '#{value}'. min=#{min}, max=#{max}"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cb-core-0.1.6 lib/codebreaker/mixins/validatable.rb
cb-core-0.1.4 lib/codebreaker/mixins/validatable.rb
cb-core-0.1.3 lib/codebreaker/mixins/validatable.rb
cb-core-0.1.2 lib/codebreaker/mixins/validatable.rb
cb-core-0.1.1 lib/codebreaker/mixins/validatable.rb
cb-core-0.1.0 lib/codebreaker/mixins/validatable.rb