Skip to content

Conversation

@juniper-shopify
Copy link
Contributor

@juniper-shopify juniper-shopify commented Nov 1, 2025

Adds an abstract a validate! method to Cog::Config that will get called once a cog instance's configs are merged. A config that fails validation will raise an exception before the workflow begins running.

This also allows config validation logic to take the full state of the config into account, if necessary (vs the previous pattern of validating individual args when they were set on the config object)


Introduces a valid_<param> and valid_<param>! accessor pattern for config class attributes. The convention I'm imagining is this:

  • boolean config setters are bang methods (exit_on_error! and no_exit_on_error!)
  • boolean config getters are equivalently named question methods (exit_on_error?)
    • boolean values are never in an invalid state and there's never a name collision here
  • most other value setters are single-argument methods that take a value (parallel 3)
  • getters for other values are methods with the valid_ prefix (valid_parallel!)
    • method uses the ! suffix if it performs validation and might throw
    • method uses no bang suffix if it does not perform validation and will always return a valid or default value
    • this prevents name collision between the setters and getters, makes it clear that a validated value is being used, and allows us to narrow the type annotation on getters that, e.g., will not produce nils.

@juniper-shopify juniper-shopify force-pushed the juni/10-31-add_validation_to_cog_configs branch from 21dbd44 to 1972767 Compare November 3, 2025 16:05
@juniper-shopify juniper-shopify changed the base branch from juni/add-global-config to graphite-base/512 November 3, 2025 16:11
@juniper-shopify juniper-shopify force-pushed the juni/10-31-add_validation_to_cog_configs branch from 1972767 to a5361cb Compare November 3, 2025 16:11
@graphite-app graphite-app bot changed the base branch from graphite-base/512 to main November 3, 2025 16:11
@juniper-shopify juniper-shopify force-pushed the juni/10-31-add_validation_to_cog_configs branch from a5361cb to 773d9da Compare November 3, 2025 16:11
@juniper-shopify juniper-shopify merged commit a526c67 into main Nov 3, 2025
13 of 14 checks passed
Copy link
Contributor Author

Merge activity

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.

2 participants