Skip to content

Conversation

@afuno
Copy link
Member

@afuno afuno commented Jun 28, 2025

input :service_class,
      type: Class,
      target: MyFirstService
input :service_class,
      type: Class,
      target: {
        in: MyFirstService,
        message: "Custom error"
      }
input :service_class,
      type: Class,
      target: {
        in: [MyFirstService, MySecondService],
        message: lambda { |input:, value:, option_value:, **|
          "Input `#{input.name}`: `#{value}` is not allowed. " \
            "Allowed: #{Array(option_value).map(&:name).join(', ')}"
        }
      }

@afuno afuno added this to the v2.16.0 milestone Jun 28, 2025
@afuno afuno self-assigned this Jun 28, 2025
@afuno afuno added the feature label Jun 28, 2025
@afuno afuno marked this pull request as ready for review June 29, 2025 13:19
@afuno afuno modified the milestones: v2.16.0, v.2.17.0 Aug 23, 2025
afuno added 5 commits October 15, 2025 00:32
- Added `# rubocop:disable Naming/PredicateMethod` comments to methods in `Inclusion` and `Target` classes to suppress style warnings.
- Ensured methods maintain clarity and functionality while adhering to project's style requirements.
Accept main's configuration architecture (Config + Configurable + dup_for_inheritance)
and dynamic options validation improvements (nil guards, reason handling).

Preserve feature branch's new `target` dynamic option implementation.
- Centralized inclusion value normalization into a new private method `normalize_inclusion_values`.
- Updated multiple methods (`condition_for_input_with`, `condition_for_internal_with`, `condition_for_output_with`) to use normalized inclusion values for consistency.
- Improved code readability and reduced duplication by reusing `normalize_inclusion_values`.
- Added a safeguard to handle non-array option values gracefully by wrapping them in an array.
- Introduced a guard clause to handle `nil` values in dynamic option configurations for inputs, internals, and outputs.
- Updated error messages to reflect missing values more clearly with a new `invalid_option` reason in both English and Russian locales.
- Enhanced the `Target` toolkit with improved validation logic for dynamic options.
- Added comprehensive RSpec coverage for all newly introduced scenarios.
- Ensured backwards compatibility by maintaining existing behavior for valid configurations.
- Refactored `TargetMatcher` and `InclusionMatcher` to improve validation for nil values and non-hash attributes.
- Centralized value formatting into new private methods (`formatted_values`, `normalize_to_array`) for clarity and reuse.
- Enhanced logic for checking attribute presence and inclusion with guard clauses.
- Reduced code duplication and improved error message generation for missing options.
@afuno afuno merged commit cb41b8e into main Dec 26, 2025
37 checks passed
@afuno afuno deleted the features/SRV-248/type_class branch December 26, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants