Class: Cliqr::ValidationErrors Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cliqr/validation_errors.rb

Overview

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

A wrapper of validation errors which provides helpful methods for accessing it

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeValidationErrors

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.

Create a new instance of the validation error wrapper



16
17
18
# File 'lib/cliqr/validation_errors.rb', line 16

def initialize
  @errors = Set.new []
end

Instance Attribute Details

#errorsArray<String]

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.

List of all error messages

Returns:

  • (Array<String])

    Array<String]



13
14
15
# File 'lib/cliqr/validation_errors.rb', line 13

def errors
  @errors
end

Instance Method Details

#add(error_message) ⇒ Array

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.

Add a new error message

Parameters:

  • error_message (String)

Returns:

  • (Array)

    A collection of all error messages



25
26
27
# File 'lib/cliqr/validation_errors.rb', line 25

def add(error_message)
  @errors.add(error_message)
end

#each(&block) ⇒ Set<String>

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.

Iterate over each error message

Parameters:

  • block (Function)

    The iterating function

Returns:

  • (Set<String>)

    A set of all error messages



57
58
59
# File 'lib/cliqr/validation_errors.rb', line 57

def each(&block)
  @errors.each(&block)
end

#empty?Boolean

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.

Check if there are error or not

Returns:

  • (Boolean)

    false if there are no errors



32
33
34
# File 'lib/cliqr/validation_errors.rb', line 32

def empty?
  @errors.empty?
end

#merge(other) ⇒ Cliqr::Validation::Errors

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.

Merge the list of errors from another

Parameters:

  • other (Cliqr::Validation::Errors)

    Errors that need to be merged

Returns:

  • (Cliqr::Validation::Errors)

    Updated errors list



48
49
50
# File 'lib/cliqr/validation_errors.rb', line 48

def merge(other)
  @errors = @errors.union(other.errors)
end

#to_sString

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.

Convert list of errors to a string representation

Returns:

  • (String)

    A comma separated list of all errors



39
40
41
# File 'lib/cliqr/validation_errors.rb', line 39

def to_s
  @errors.to_a.join(', ')
end