feat: Add coreex-validator skill#155
Merged
Merged
Conversation
- .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>
Contributor
There was a problem hiding this comment.
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-validatorskill 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-validatorprompt bridge and updatedCoreEx.Template.csprojto 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. |
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>
… 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>
- 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>
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
coreex-validatorskill — a structured, multi-path workflow for creating or extending CoreEx validators inApplication/Validators/.Files Added
.github/skills/coreex-validator/SKILL.md.github/skills/coreex-validator/references/workflow.md.github/prompts/coreex-validator.prompt.md/coreex-validatorprompt bridgeFiles Modified
src/CoreEx.Template/CoreEx.Template.csproj_AiFileBootstrap entries +Copyblock to distribute skill viadotnet new coreex-bootstrapanddotnet new coreex-aiSkill Paths
Validator<T, TSelf>: no injection,Defaultsingleton, all rules declarative in constructorValidator<T>with injection: constructor-injected dependency,OnValidateAsyncfor I/O checks,ValidateFurtherAsyncfor post-I/O declarative rulesAbstractValidator<T, TSelf>: FluentValidation-compatibleRuleForAPI, still CoreEx under the hoodOnValidateAsync, correctHasErrorsvsHasError(x => x.Prop)guard choiceKey Conventions Encoded
.IsValid()), never the*CodestringWhenValuepredicate is on the property value;WhenEntitypredicate is on the entity (documented in A2 table)GetCollectionIndex()— zero-based index fromCollectionRule; use in rule delegate overloads (e.g.GreaterThanOrEqualTo(ctx => items[ctx.GetCollectionIndex()]...));.Error()takesLTextnot a delegateAbstractValidatorisCoreEx.Validation.AbstractValidator{Validator}Testsin*.Test.Unit/Validators/usingTest.Scoped(...)withXxxValidator.Default