Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate settings even if loader does not set value #246

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

oeoeaio
Copy link
Contributor

@oeoeaio oeoeaio commented Sep 5, 2022

Resolves #245

This is probably not the right way to solve this, but it gives the intended effect.

@oeoeaio oeoeaio requested a review from solnic as a code owner September 5, 2022 01:46
it "defines the setting" do
expect(container[:settings].some_int_using_deprecated_key).to eq 5
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to tweak this because this spec 👇 was failing with a validation error.

settings_obj.config.public_send(:"#{setting_name}=", value)
else
settings_obj.config[setting_name]
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, if the loaded doesn't find a value, we still evaluate the setting to make sure the constructor is happy with the setting being nil.

@oeoeaio
Copy link
Contributor Author

oeoeaio commented Oct 18, 2022

@solnic is there anything I can do to move this along?

@timriley
Copy link
Member

@oeoeaio Thank you for submitting this, and sorry for the delay here! I've actually just addressed this same issue in Hanami (hanami/hanami#1222), which does not use the dry-system settings plugin but does a very similar thing.

I can commit to checking out your PR sometime in the next ~week and have it be released.

@oeoeaio
Copy link
Contributor Author

oeoeaio commented Oct 23, 2022

That would be great, thanks @timriley.

@timriley
Copy link
Member

Thanks for taking care of this, @oeoeaio! This fix is perfect :)

@timriley timriley merged commit 64fcaf6 into dry-rb:main Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing settings are not validated
2 participants