Class: EasyTalk::ValidationBuilder Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_talk/validation_builder.rb

Overview

Deprecated.

Use EasyTalk::ValidationAdapters::ActiveModelAdapter instead.

The ValidationBuilder class is kept for backward compatibility. It delegates to the ActiveModelAdapter and shows a deprecation warning.

This class will be removed in a future major version.

Examples:

Migration

# Before (deprecated)
EasyTalk::ValidationBuilder.build_validations(klass, :name, String, {})

# After (recommended)
EasyTalk::ValidationAdapters::ActiveModelAdapter.build_validations(klass, :name, String, {})

Class Method Summary collapse

Class Method Details

.build_validations(klass, property_name, type, constraints)

Deprecated.

Use EasyTalk::ValidationAdapters::ActiveModelAdapter.build_validations instead.

This method returns an undefined value.

Build validations for a property and apply them to the model class.

Parameters:

  • klass (Class)

    The model class to apply validations to

  • property_name (Symbol, String)

    The name of the property

  • type (Class, Object)

    The type of the property

  • constraints (Hash)

    The JSON Schema constraints for the property



30
31
32
33
34
35
36
37
38
# File 'lib/easy_talk/validation_builder.rb', line 30

def self.build_validations(klass, property_name, type, constraints)
  unless @deprecation_warned
    warn "[DEPRECATION] EasyTalk::ValidationBuilder is deprecated and will be removed in a future version. " \
         "Use EasyTalk::ValidationAdapters::ActiveModelAdapter instead."
    @deprecation_warned = true
  end

  ValidationAdapters::ActiveModelAdapter.build_validations(klass, property_name, type, constraints)
end

.reset_deprecation_warning!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.

Reset the deprecation warning flag (useful for testing).



43
44
45
# File 'lib/easy_talk/validation_builder.rb', line 43

def self.reset_deprecation_warning!
  @deprecation_warned = false
end