Skip to content

feat: Add coreex-validator skill#155

Merged
chullybun merged 11 commits into
mainfrom
skills/coreex-validator
Jun 30, 2026
Merged

feat: Add coreex-validator skill#155
chullybun merged 11 commits into
mainfrom
skills/coreex-validator

Conversation

@chullybun

Copy link
Copy Markdown
Collaborator

Summary

Adds the coreex-validator skill — a structured, multi-path workflow for creating or extending CoreEx validators in Application/Validators/.

Files Added

File Purpose
.github/skills/coreex-validator/SKILL.md Lean entry point (≤300 lines): 4-path decision model, base-class table, clarifying questions, key rules
.github/skills/coreex-validator/references/workflow.md Full procedural content: all 4 paths, nested validators (collection + dictionary), GetCollectionIndex/GetDictionaryKey patterns, guardrails
.github/prompts/coreex-validator.prompt.md VS Code / VS / GitHub.com /coreex-validator prompt bridge

Files Modified

File Change
src/CoreEx.Template/CoreEx.Template.csproj Added _AiFile Bootstrap entries + Copy block to distribute skill via dotnet new coreex-bootstrap and dotnet new coreex-ai

Skill Paths

  • Path AValidator<T, TSelf>: no injection, Default singleton, all rules declarative in constructor
  • Path BValidator<T> with injection: constructor-injected dependency, OnValidateAsync for I/O checks, ValidateFurtherAsync for post-I/O declarative rules
  • Path CAbstractValidator<T, TSelf>: FluentValidation-compatible RuleFor API, still CoreEx under the hood
  • Path D — Add rules to existing validator: extend constructor or OnValidateAsync, correct HasErrors vs HasError(x => x.Prop) guard choice

Key Conventions Encoded

  • Ref-data: validate navigation property (.IsValid()), never the *Code string
  • WhenValue predicate is on the property value; WhenEntity predicate is on the entity (documented in A2 table)
  • GetCollectionIndex() — zero-based index from CollectionRule; use in rule delegate overloads (e.g. GreaterThanOrEqualTo(ctx => items[ctx.GetCollectionIndex()]...)); .Error() takes LText not a delegate
  • Never use the FluentValidation NuGet package — AbstractValidator is CoreEx.Validation.AbstractValidator
  • Test offer: always offer matching {Validator}Tests in *.Test.Unit/Validators/ using Test.Scoped(...) with XxxValidator.Default

chullybun and others added 3 commits June 30, 2026 08:41
- .github/skills/coreex-validator/SKILL.md — 4-path model (Validator<T,TSelf>, Validator<T> with injection, AbstractValidator, add rules), base-class decision table, key rules quick-reference
- .github/skills/coreex-validator/references/workflow.md — full workflow: declarative rules, async OnValidateAsync with HasErrors/HasError guards, ValidateFurtherAsync, nested collection + dictionary validators, test coupling, guardrails
- .github/prompts/coreex-validator.prompt.md — VS Code / VS / GitHub.com bridge wrapper
- CoreEx.Template.csproj — _AiFile (Bootstrap) + Copy block (CoreEx.Ai)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Documents ctx.GetCollectionIndex() (zero-based int, set by CollectionRule during enumeration)
as the collection equivalent of ctx.GetDictionaryKey<T>(). Includes note on IndexOutOfRangeException
when called outside a collection context.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dex Error() overload, D1 cross-reference

- A2 table: replace misleading WhenValue(x => x.SomeFlag) with accurate WhenEntity/WhenValue distinction (WhenValue predicate is on property value, WhenEntity on entity)
- GetCollectionIndex example: .Error() takes LText not a Func — show delegate overload of GreaterThanOrEqualTo instead
- D1: fix stale cross-reference to coreex-validator.SKILL.md (doesn't exist) → coreex-contracts.instructions.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 16:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new coreex-validator skill (and its prompt wrapper) to guide creation/extension of CoreEx Application-layer validators, and wires the new assets into the template packaging so they ship via coreex-bootstrap / coreex-ai.

Changes:

  • Added coreex-validator skill entrypoint (SKILL.md) with a 4-path decision model and key guardrails.
  • Added detailed validator workflow reference (references/workflow.md) covering declarative, injected/async, AbstractValidator, and nested collection/dictionary patterns.
  • Added /coreex-validator prompt bridge and updated CoreEx.Template.csproj to distribute the new prompt + skill files via templates.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/CoreEx.Template/CoreEx.Template.csproj Includes the new prompt/skill files in Bootstrap generation and CoreEx.Ai copy/pack steps.
.github/skills/coreex-validator/SKILL.md Adds the concise skill entrypoint and quick reference/decision table for validator authoring.
.github/skills/coreex-validator/references/workflow.md Adds the full multi-path workflow and examples for validators (including nested collection/dictionary patterns).
.github/prompts/coreex-validator.prompt.md Adds the prompt wrapper that routes /coreex-validator usage to the skill/workflow as the authority.

Comment thread .github/skills/coreex-validator/references/workflow.md Outdated
chullybun and others added 2 commits June 30, 2026 09:54
Add EntityRule / .Entity() section before Collection and Dictionary in the
Nested Validators section, covering all three forms:
- Form 1: direct IValidatorEx<T> instance (Default singleton)
- Form 2: DI-resolved via WithValidator<TValidator>()
- Form 3: inline Action<InlineValidator> for one-off rules

Documents nested path merging behaviour (address.street, not street).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ymbols

Replace the Path B scaffold with a clean generic example that doesn't
reference symbols declared elsewhere in the document.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 17:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread .github/skills/coreex-validator/references/workflow.md
chullybun and others added 2 commits June 30, 2026 10:08
… to Use

The most common nested validator pattern was missing from the skill entry
point. Add Entity/.Entity() to frontmatter description and When to Use list.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The sample IProductRepository.GetForReservationAsync does not accept a
CancellationToken. Align the skill example with the real interface signature.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread .github/skills/coreex-validator/references/workflow.md Outdated
Comment thread .github/skills/coreex-validator/references/workflow.md Outdated
chullybun and others added 2 commits June 30, 2026 10:14
- B2 OnValidateAsync: ValidationContext<{Name}> -> ValidationContext<Contracts.{Name}>
  to match the Validator<Contracts.{Name}> base class declaration
- D2: correct guidance — Validator<T, TSelf> supports OnValidateAsync natively;
  only switch to Validator<T> when constructor injection is actually needed,
  not merely because async validation is required

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Async-only OnValidateAsync does not require Path B — only constructor
injection does. Update the clarifying question to reflect this.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread .github/skills/coreex-validator/SKILL.md
Comment thread .github/skills/coreex-validator/references/workflow.md Outdated
chullybun and others added 2 commits June 30, 2026 10:21
…tion

The established repo pattern (MovementService) instantiates Validator<T>
at the call site using already-injected dependencies:
  new MovementRequestValidator(_repository).ValidateAndThrowAsync(...)

Update SKILL.md base class table and B3 to reflect this. DI registration
is noted as an option but not the primary pattern.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@chullybun chullybun merged commit af55ecc into main Jun 30, 2026
4 checks passed
@chullybun chullybun deleted the skills/coreex-validator branch June 30, 2026 17:35
@chullybun chullybun added this to the v4.0.0-preview-2 milestone Jul 6, 2026
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