Class: Dbviewer::Validator::Sql::ValidationResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/dbviewer/validator/sql/validation_result.rb

Overview

Validation result object to encapsulate validation state and errors This provides a structured way to return validation results with clear success/failure states and associated error messages.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#error_messageObject

Returns the value of attribute error_message

Returns:

  • (Object)

    the current value of error_message



9
10
11
# File 'lib/dbviewer/validator/sql/validation_result.rb', line 9

def error_message
  @error_message
end

#normalized_sqlObject

Returns the value of attribute normalized_sql

Returns:

  • (Object)

    the current value of normalized_sql



9
10
11
# File 'lib/dbviewer/validator/sql/validation_result.rb', line 9

def normalized_sql
  @normalized_sql
end

#valid?Object

Returns the value of attribute valid?

Returns:

  • (Object)

    the current value of valid?



9
10
11
# File 'lib/dbviewer/validator/sql/validation_result.rb', line 9

def valid?
  @valid?
end

Class Method Details

.failure(error_message) ⇒ ValidationResult

Create a failed validation result

Parameters:

  • error_message (String)

    Description of the validation failure

Returns:



32
33
34
# File 'lib/dbviewer/validator/sql/validation_result.rb', line 32

def self.failure(error_message)
  new(valid?: false, error_message: error_message)
end

.success(normalized_sql) ⇒ ValidationResult

Create a successful validation result

Parameters:

  • normalized_sql (String)

    The normalized SQL query

Returns:



25
26
27
# File 'lib/dbviewer/validator/sql/validation_result.rb', line 25

def self.success(normalized_sql)
  new(valid?: true, normalized_sql: normalized_sql)
end

Instance Method Details

#failure?Boolean

Check if the validation failed

Returns:

  • (Boolean)

    true if validation failed



18
19
20
# File 'lib/dbviewer/validator/sql/validation_result.rb', line 18

def failure?
  !valid?
end

#success?Boolean

Check if the validation was successful

Returns:

  • (Boolean)

    true if validation passed



12
13
14
# File 'lib/dbviewer/validator/sql/validation_result.rb', line 12

def success?
  valid?
end