Sha256: 02591ac46d902b3124de5855454bb66160721845a9eb6902b0a58009afaf8085

Contents?: true

Size: 392 Bytes

Versions: 14

Compression:

Stored size: 392 Bytes

Contents

require 'haveapi/client/validator'

module HaveAPI::Client
  class Validators::Length < Validator
    name :length

    def valid?
      len = value.length

      return len == opts[:equals] if opts[:equals]
      return len >= opts[:min] if opts[:min] && !opts[:max]
      return len <= opts[:max] if !opts[:min] && opts[:max]

      len >= opts[:min] && len <= opts[:max]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
haveapi-client-0.25.0 lib/haveapi/client/validators/length.rb
haveapi-client-0.24.0 lib/haveapi/client/validators/length.rb
haveapi-client-0.23.7 lib/haveapi/client/validators/length.rb
haveapi-client-0.23.6 lib/haveapi/client/validators/length.rb
haveapi-client-0.23.5 lib/haveapi/client/validators/length.rb
haveapi-client-0.23.4 lib/haveapi/client/validators/length.rb
haveapi-client-0.23.3 lib/haveapi/client/validators/length.rb
haveapi-client-0.23.2 lib/haveapi/client/validators/length.rb
haveapi-client-0.23.1 lib/haveapi/client/validators/length.rb
haveapi-client-0.23.0 lib/haveapi/client/validators/length.rb
haveapi-client-0.22.1 lib/haveapi/client/validators/length.rb
haveapi-client-0.22.0 lib/haveapi/client/validators/length.rb
haveapi-client-0.21.1 lib/haveapi/client/validators/length.rb
haveapi-client-0.21.0 lib/haveapi/client/validators/length.rb