Skip to content

feat(figue): add cross-field validation support#22

Merged
CorentinTh merged 1 commit into
mainfrom
post-parsing
Jun 21, 2026
Merged

feat(figue): add cross-field validation support#22
CorentinTh merged 1 commit into
mainfrom
post-parsing

Conversation

@CorentinTh

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces cross-field (per-field hook) validation to defineConfig, enabling rules that validate a field using the fully validated/coerced config object (e.g., “defaultAdapterId must exist in adapters[]”).

Changes:

  • Added validate hook support on config definition leaves, executed after successful schema validation, aggregating issues into the existing ConfigValidationError.
  • Added public validation types (ValidateFn, ValidateIssue, ValidateResult) and a validator(...) helper for improved typing ergonomics.
  • Documented cross-field validation usage in the README and added comprehensive tests for the new behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/index.ts Re-exports validator and validation-related types as part of the public API.
src/figue.types.ts Introduces the validate hook types and adds validate to ConfigDefinitionElement.
src/figue.ts Implements validate hook execution/normalization and exposes the validator helper.
src/figue.test.ts Adds tests covering validate hook contracts, error aggregation, and typed helper usage.
README.md Adds user-facing documentation for cross-field validation and return contracts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/figue.types.ts
Comment thread src/figue.ts
Comment on lines +99 to +101
export function validator<Config = any, Value = any>(fn: ValidateFn<Value, Config>): ValidateFn<Value, Config> {
return fn;
}
@CorentinTh CorentinTh merged commit c75dacc into main Jun 21, 2026
3 checks passed
@CorentinTh CorentinTh deleted the post-parsing branch June 21, 2026 15:12
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