Module: Hanami::Validations Private

Defined in:
lib/hanami/validations.rb,
lib/hanami/validations/form.rb,
lib/hanami/validations/version.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Defined Under Namespace

Modules: ClassMethods, Form Classes: Result

Constant Summary collapse

VERSION =

The current hanami-validations version.

Since:

  • 0.1.0

"2.1.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.gem_loaderObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hanami/validations.rb', line 15

def self.gem_loader
  @gem_loader ||= Zeitwerk::Loader.new.tap do |loader|
    root = File.expand_path("..", __dir__)
    loader.tag = "hanami-validations"
    loader.inflector = Zeitwerk::GemInflector.new("#{root}/hanami-validations.rb")
    loader.push_dir(root)
    loader.ignore(
      "#{root}/hanami-validations.rb",
      "#{root}/hanami/validations/version.rb"
    )
  end
end

.included(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



33
34
35
36
# File 'lib/hanami/validations.rb', line 33

def self.included(klass)
  super
  klass.extend(ClassMethods)
end

Instance Method Details

#initialize(input) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a new instance of a validator

Parameters:

  • input (#to_h)

    a set of input data

Since:

  • 0.6.0



82
83
84
# File 'lib/hanami/validations.rb', line 82

def initialize(input)
  @input = input
end

#to_hHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a Hash with the defined attributes as symbolized keys, and their relative values.

Returns:

  • (Hash)

Since:

  • 0.1.0



105
106
107
# File 'lib/hanami/validations.rb', line 105

def to_h
  validate.to_h
end

#validateHanami::Validations::Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Validates the object.

Returns:

Since:

  • 0.2.4



92
93
94
95
96
# File 'lib/hanami/validations.rb', line 92

def validate
  Result.new(
    self.class._validator.call(@input)
  )
end