[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EA2QMMZQNCNGBABV809VDK":3,"skill-same:01M7EA2QMMZQNCNGBABV809VDK":98},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":13,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M7EA2QMMZQNCNGBABV809VDK","fluentvalidation",null,"Validators with FluentValidation 12 in .NET code. Covers rules, cascade mode, error codes, child and collection validators, async rules, DI registration, the call from a minimal API endpoint filter, a controller, or a worker, the error response with stable codes, and validator tests. Use when code or a review touches AbstractValidator, RuleFor, RuleForEach, MustAsync, WithErrorCode, CascadeMode, SetValidator, IValidator, ValidateAsync, AddValidatorsFromAssemblyContaining, TestValidate, InlineValidator, FluentValidation.AspNetCore, or a move from DataAnnotations or AddValidation to FluentValidation. Not for the built-in AddValidation with DataAnnotations alone, ProblemDetails wiring, or endpoint design (dev-stack:aspnetcore), options validation at startup, or domain invariants inside entities (dev-stack:csharp).","Charmedme\u002Fmaikelsoft-skills","Charmedme","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F11330182?v=4","01M7E9YWP4Z4JJ1BRXTMWNXAEV","01M7E9YWPS4N3GKRGAYBBDJWNQ",0,"MIT","https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: fluentvalidation\ndescription: Validators with FluentValidation 12 in .NET code. Covers rules, cascade mode, error codes, child and collection validators, async rules, DI registration, the call from a minimal API endpoint filter, a controller, or a worker, the error response with stable codes, and validator tests. Use when code or a review touches AbstractValidator, RuleFor, RuleForEach, MustAsync, WithErrorCode, CascadeMode, SetValidator, IValidator, ValidateAsync, AddValidatorsFromAssemblyContaining, TestValidate, InlineValidator, FluentValidation.AspNetCore, or a move from DataAnnotations or AddValidation to FluentValidation. Not for the built-in AddValidation with DataAnnotations alone, ProblemDetails wiring, or endpoint design (dev-stack:aspnetcore), options validation at startup, or domain invariants inside entities (dev-stack:csharp).\nmetadata:\n  verified: \"2026-10-27\"\n  versions: \"FluentValidation 12.2.0 and FluentValidation.DependencyInjectionExtensions 12.2.0 (net8.0 and later), .NET 10 (SDK 10.0.403)\"\n---\n\n# FluentValidation\n\nValidators and the call that runs them. The endpoint, ProblemDetails, and the built-in `AddValidation` are in `dev-stack:aspnetcore`. This skill also works in a worker or a library without a web host.\n\n## First\n\n1. Read `references\u002Fstack-rules.md`.\n2. Read the version gate:\n   - The `FluentValidation*` packages in `*.csproj` or `Directory.Packages.props`.\n   - 12.x: use this file.\n   - 11.x: the rules apply, but the 12.0 removals still compile there. Tell the human about the upgrade. Do not upgrade unless the task asks for it. The upgrade steps are in `references\u002Fvalidators.md`.\n   - `FluentValidation.AspNetCore` in the project: its owner deprecated it. Plan its removal (rule 1).\n3. Find the other validation in the same request path. Look for `builder.Services.AddValidation()`, DataAnnotations on the request records, `[ApiController]` model validation, and manual checks in the handler.\n\nDone when you can name the FluentValidation version, the call site (filter, controller, worker), and each other validation that runs for the same request type.\n\n## Defaults for new code\n\nExisting code keeps its style. For new code, use the accepted decision in `docs\u002Fdev-team\u002Fdecisions.md`. When a decision has no accepted answer, ask the human (stack rule 4). The detail is in `references\u002Fdecisions.md`.\n\n| Area | Default | ID |\n|------|---------|----|\n| Library | FluentValidation when the project uses it. Built-in `AddValidation` for shape rules only | API-08 |\n| Error codes to the client | `code = \"validation.failed\"` plus an `errorCodes` map per field, the same shape for both validation paths | API-20 |\n| Code format | `WithErrorCode` in the format of the ProblemDetails `code` (`order.sku_unknown`) | API-04 |\n| Call site | One generic endpoint filter for minimal APIs. An explicit `ValidateAsync` in controllers and workers | API-08 |\n| Auto-validation packages | None: no `FluentValidation.AspNetCore`, no SharpGrip | API-08 |\n| Lifetime | The library default (scoped) | - |\n| Uniqueness and state | A unique index with 409, and the rule in the domain. A validator check is only an early message | - |\n\n## Rules\n\n### Packages and registration\n\n1. Reference `FluentValidation` and `FluentValidation.DependencyInjectionExtensions` with the same 12.x version. Do not add `FluentValidation.AspNetCore`: its owner deprecated it, and it works for MVC only. Its auto-validation cannot run async rules: a validator with an async rule throws `AsyncValidatorInvokedSynchronouslyException` at run time.\n2. Register with `services.AddValidatorsFromAssemblyContaining\u003CT>()` and `using FluentValidation;`. The namespace `FluentValidation.DependencyInjectionExtensions` does not exist, although a docs page shows it (CS0234).\n3. Make validators `public`, or pass `includeInternalTypes: true`. The scan skips `internal` validators, and the gap shows only at runtime as a DI error.\n4. Keep the default lifetime (scoped). A singleton validator that takes a `DbContext` or another scoped service holds one instance for all requests.\n\n### The call\n\n5. Call `await validator.ValidateAsync(model, ct)` in async code. `Validate` on a validator with a `MustAsync` rule throws `AsyncValidatorInvokedSynchronouslyException`. A later async rule then turns each request into a 500.\n6. Check the model for null before the call. `ValidateAsync(null)` throws `InvalidOperationException`. In Production, minimal APIs run the endpoint filters with a JSON `null` body, so a filter gets null (tested). In Development, `ThrowOnBadRequest` throws `BadHttpRequestException` before the filters, so a test in Development does not show the problem.\n7. Validate one request type with one library. With `AddValidation()` in the project, remove the DataAnnotations from a type with a validator. Or call `.DisableValidation()` on the endpoint. The built-in filter runs first and returns its own 400 (tested). The validator then never runs for that field, and the client sees two error styles.\n8. Return `TypedResults.ValidationProblem(result.ToDictionary(), extensions: ...)` with the codes in an extension (decision API-20). `ToDictionary()` carries the messages only. The default `ErrorCode` is the validator name (`NotEmptyValidator`), which is not a contract.\n\nFilter, controller, worker, and the error shape: `references\u002Fcall-sites.md`.\n\n### Rules in a validator\n\n9. Set `WithErrorCode` after each validator that a client acts on. It applies to the last validator before it, not to the whole chain. Use the format of API-04 (`order.lines_too_many`).\n10. Set `RuleLevelCascadeMode = CascadeMode.Stop` in the constructor when a later check needs an earlier one (`NotEmpty`, then `Matches`, then `MustAsync`). It stops a second message and a null access in `Must`.\n11. Do not set `ClassLevelCascadeMode = CascadeMode.Stop`. It stops the whole validator after the first rule that fails, not each field. The client then gets one field error at a time (tested).\n12. Compose with `RuleForEach(x => x.Lines).SetValidator(lineValidator)` and the child validator from the constructor. FluentValidation 12.0 removed `InjectValidator` (CS1061).\n13. `SetValidator` skips a null item or child. When the value is required, put `.NotNull().WithErrorCode(...)` before `SetValidator`, else the handler throws. Null can also be a valid value, for example an optional field on an update that keeps the current value. Then `SetValidator` without `NotNull()` is correct. Do not flag it. With `CascadeMode.Stop`, a `RuleForEach` stops at the first bad item and does not check the other items. Add `.Cascade(CascadeMode.Continue)` to that rule when the client needs an error for each item (tested).\n14. Validate the shape of the input: required, length, range, format, and cross-field rules inside one request. Keep state rules in the domain, for example \"only a placed order can ship\". Keep uniqueness in a unique index with a 409. A validator runs only on the paths that call it. Two requests can pass the same check at the same time.\n15. Read limits from the options class that holds them (`IOptions\u003CT>` in the validator constructor). Do not copy a number into a second place. When a request names a limit that differs from the option, ask which one wins.\n16. Write two validators for two contracts. Do not use rule sets for it: they hide which rules run, and they pass into child validators.\n\nRule examples and the 12.0 removals: `references\u002Fvalidators.md`.\n\n### Tests\n\n17. Test the real validator with `TestValidateAsync` (valid and invalid case per rule, and the code). Use `InlineValidator\u003CT>` when a consumer test needs a validator that fails. Do not mock `IValidator\u003CT>`: the mock hides a missing registration and a sync call.\n\nTest examples: `references\u002Ftesting.md`.\n\n## Never write\n\n| Wrong | Correct |\n|-------|---------|\n| `AddFluentValidationAutoValidation()`, `AddMvc().AddFluentValidation(...)` | `AddValidatorsFromAssemblyContaining\u003CT>()` and an endpoint filter |\n| `using FluentValidation.DependencyInjectionExtensions;` | `using FluentValidation;` |\n| `internal sealed class CreateOrderValidator` with a default scan | `public sealed class`, or `includeInternalTypes: true` |\n| `AddValidatorsFromAssemblyContaining\u003CT>(ServiceLifetime.Singleton)` with a scoped dependency | `AddValidatorsFromAssemblyContaining\u003CT>()` |\n| `var result = validator.Validate(request);` in an endpoint or filter | `var result = await validator.ValidateAsync(request, ct);` |\n| `context.GetArgument\u003CT>(0)` passed to the validator as is | `context.Arguments.OfType\u003CT>().FirstOrDefault() is not { } argument` and a 400 |\n| `CascadeMode = CascadeMode.StopOnFirstFailure;` | `RuleLevelCascadeMode = CascadeMode.Stop;` |\n| `ClassLevelCascadeMode = CascadeMode.Stop;` to get one message for each field | `RuleLevelCascadeMode = CascadeMode.Stop;` (rule 11) |\n| `RuleForEach(x => x.Lines).SetValidator(lineValidator)` when an item can be null | `RuleForEach(x => x.Lines).NotNull().WithErrorCode(\"order.line_required\").SetValidator(lineValidator)` |\n| `RuleFor(x => x.Address).InjectValidator();` | Inject `IValidator\u003CAddress>` and call `SetValidator(addressValidator)` |\n| `Transform(x => x.Name, n => n.Trim())` | Project the value in the rule expression or in the request mapping |\n| `.NotEmpty().MaximumLength(32).WithErrorCode(\"sku_invalid\")` for both checks | `.NotEmpty().WithErrorCode(\"order.sku_required\").MaximumLength(32).WithErrorCode(\"order.sku_too_long\")` |\n| `TypedResults.ValidationProblem(result.ToDictionary())` when the client reads codes | The same plus the `code` and `errorCodes` extensions (API-20) |\n| `result.Errors.GroupBy(e => e.PropertyName).ToDictionary(..., e.ErrorMessage ...)` | `result.ToDictionary()` |\n| `[Required]` on the record and a validator for the same field | One of the two (rule 7) |\n| `new Mock\u003CIValidator\u003CCreateOrder>>()`, `Substitute.For\u003CIValidator\u003C...>>()` | `new CreateOrderValidator(...)` or `new InlineValidator\u003CCreateOrder>()` |\n| `ShouldHaveAnyValidationError()` | `ShouldHaveValidationErrors()` (12.x) |\n| `MustAsync(EmailNotTakenAsync)` as the only guard | A unique index, catch the violation, return 409 |\n\n## Check\n\n1. Build with the analyzers. Pass: 0 warnings and 0 errors. The 12.0 removals fail here (CS0117, CS0118, CS0103, CS1061).\n\n   ```\n   dotnet build -warnaserror\n   ```\n\n2. Find deprecated packages. Pass: no `FluentValidation.AspNetCore`.\n\n   ```\n   dotnet list package --deprecated\n   ```\n\n3. Run the rule check of this skill. Pass: `stackcheck: 0 errors`. In an existing project, add `--changed \u003Cbase branch>`.\n\n   ```\n   python3 \u003Cskill folder>\u002Fscripts\u002Fstackcheck.py --root \u003Crepo>\n   ```\n\n4. Run the tests. Pass: all green. Each rule has a `TestValidateAsync` test (valid and invalid, with the code). Each endpoint has one HTTP test that asserts the 400 and its codes.\n\n   ```\n   dotnet test\n   ```\n\n## Review checklist\n\nThe full list is in `references\u002Freview-checklist.md`.\n\n1. No `FluentValidation.AspNetCore`, no `AddFluentValidation*`. tool (FV-PKG-ASPNETCORE, FV-AUTOVALIDATION)\n2. Each call is `ValidateAsync` with the token. tool (FV-SYNC-VALIDATE)\n3. A filter checks the argument for null before the call. judge\n4. Validators are `public`, or the scan has `includeInternalTypes: true`. judge\n5. The lifetime is the default, or no validator takes a scoped service. tool (FV-SINGLETON) and judge\n6. One library per request type: no DataAnnotations and no `AddValidation` filter next to a validator. judge\n7. Each rule that a client acts on has its own `WithErrorCode`. The codes reach the response (API-20). tool (FV-MANUAL-DICTIONARY) and judge\n8. `RuleLevelCascadeMode = CascadeMode.Stop` where a check needs an earlier one. No `ClassLevelCascadeMode = CascadeMode.Stop`. tool (FV-CASCADE-DEPENDENT, FV-CLASS-CASCADE-STOP)\n9. Child validators come in through the constructor and `SetValidator`. A `RuleForEach` with items that can be null has `NotNull()`. tool (CS1061 for `InjectValidator`) and judge\n10. No state rule or uniqueness check as the only guard in a validator. judge\n11. Limits come from the options class, not from a second literal. judge\n12. Tests use the real validator or `InlineValidator\u003CT>`, not a mock. tool (FV-MOCK-VALIDATOR)\n13. The endpoint documents its 400 (`ProducesValidationProblem`, `dev-stack:aspnetcore-openapi`). judge\n\n## Existing code\n\nStack rule 3 applies. For this skill, check these defects in the existing code that the change touches:\n\n- A sync `Validate` call on a validator that gets a `MustAsync` rule, also in an import or a worker without an HTTP test (rule 5).\n- A filter without a null check, or that returns `ToDictionary()` without the codes (rules 6 and 8).\n- DataAnnotations on a type that gets a validator while `AddValidation()` is on (rule 7).\n- One `WithErrorCode` after a chain of validators (rule 9), and a limit that the handler checks a second time (rule 15).\n\n## Report\n\nEnd with the report of stack rule 8 (`references\u002Fstack-rules.md`). Output text follows `references\u002Flanguage.md`.\n\nAfter a change to an endpoint, add a table of the error codes below the \"Changes\" table. Give each code that a client can get from the endpoint, with its field (the property path, for example `Lines[0].Sku`) and the HTTP status. Also give where the code is in the response (the `errorCodes` extension, decision API-20). Include the existing codes that the endpoint keeps. The client team builds on this list.\n\n## References\n\n- `references\u002Fvalidators.md`: read when you write a validator, a child or collection rule, an async rule, or upgrade from 11.x.\n- `references\u002Fcall-sites.md`: read when you call a validator from an endpoint filter, a controller, or a worker, or shape the error response.\n- `references\u002Ftesting.md`: read before you write a validator test or an endpoint test that involves validation.\n- `references\u002Fdecisions.md`: read when new code needs decision API-08 or API-20.\n- `references\u002Freview-checklist.md`: read when you review a change.\n- `references\u002Fsources.md`: the primary sources and the date of each check.\n- `references\u002Fstack-rules.md`: the common rules of each dev-stack skill.\n- `references\u002Flanguage.md`: the rules for text output.\n- `scripts\u002Fstackcheck.py`: the rule check of this skill.\n","# FluentValidation\n\nValidators and the call that runs them. The endpoint, ProblemDetails, and the built-in `AddValidation` are in `dev-stack:aspnetcore`. This skill also works in a worker or a library without a web host.\n\n## First\n\n1. Read `references\u002Fstack-rules.md`.\n2. Read the version gate:\n   - The `FluentValidation*` packages in `*.csproj` or `Directory.Packages.props`.\n   - 12.x: use this file.\n   - 11.x: the rules apply, but the 12.0 removals still compile there. Tell the human about the upgrade. Do not upgrade unless the task asks for it. The upgrade steps are in `references\u002Fvalidators.md`.\n   - `FluentValidation.AspNetCore` in the project: its owner deprecated it. Plan its removal (rule 1).\n3. Find the other validation in the same request path. Look for `builder.Services.AddValidation()`, DataAnnotations on the request records, `[ApiController]` model validation, and manual checks in the handler.\n\nDone when you can name the FluentValidation version, the call site (filter, controller, worker), and each other validation that runs for the same request type.\n\n## Defaults for new code\n\nExisting code keeps its style. For new code, use the accepted decision in `docs\u002Fdev-team\u002Fdecisions.md`. When a decision has no accepted answer, ask the human (stack rule 4). The detail is in `references\u002Fdecisions.md`.\n\n| Area | Default | ID |\n|------|---------|----|\n| Library | FluentValidation when the project uses it. Built-in `AddValidation` for shape rules only | API-08 |\n| Error codes to the client | `code = \"validation.failed\"` plus an `errorCodes` map per field, the same shape for both validation paths | API-20 |\n| Code format | `WithErrorCode` in the format of the ProblemDetails `code` (`order.sku_unknown`) | API-04 |\n| Call site | One generic endpoint filter for minimal APIs. An explicit `ValidateAsync` in controllers and workers | API-08 |\n| Auto-validation packages | None: no `FluentValidation.AspNetCore`, no SharpGrip | API-08 |\n| Lifetime | The library default (scoped) | - |\n| Uniqueness and state | A unique index with 409, and the rule in the domain. A validator check is only an early message | - |\n\n## Rules\n\n### Packages and registration\n\n1. Reference `FluentValidation` and `FluentValidation.DependencyInjectionExtensions` with the same 12.x version. Do not add `FluentValidation.AspNetCore`: its owner deprecated it, and it works for MVC only. Its auto-validation cannot run async rules: a validator with an async rule throws `AsyncValidatorInvokedSynchronouslyException` at run time.\n2. Register with `services.AddValidatorsFromAssemblyContaining\u003CT>()` and `using FluentValidation;`. The namespace `FluentValidation.DependencyInjectionExtensions` does not exist, although a docs page shows it (CS0234).\n3. Make validators `public`, or pass `includeInternalTypes: true`. The scan skips `internal` validators, and the gap shows only at runtime as a DI error.\n4. Keep the default lifetime (scoped). A singleton validator that takes a `DbContext` or another scoped service holds one instance for all requests.\n\n### The call\n\n5. Call `await validator.ValidateAsync(model, ct)` in async code. `Validate` on a validator with a `MustAsync` rule throws `AsyncValidatorInvokedSynchronouslyException`. A later async rule then turns each request into a 500.\n6. Check the model for null before the call. `ValidateAsync(null)` throws `InvalidOperationException`. In Production, minimal APIs run the endpoint filters with a JSON `null` body, so a filter gets null (tested). In Development, `ThrowOnBadRequest` throws `BadHttpRequestException` before the filters, so a test in Development does not show the problem.\n7. Validate one request type with one library. With `AddValidation()` in the project, remove the DataAnnotations from a type with a validator. Or call `.DisableValidation()` on the endpoint. The built-in filter runs first and returns its own 400 (tested). The validator then never runs for that field, and the client sees two error styles.\n8. Return `TypedResults.ValidationProblem(result.ToDictionary(), extensions: ...)` with the codes in an extension (decision API-20). `ToDictionary()` carries the messages only. The default `ErrorCode` is the validator name (`NotEmptyValidator`), which is not a contract.\n\nFilter, controller, worker, and the error shape: `references\u002Fcall-sites.md`.\n\n### Rules in a validator\n\n9. Set `WithErrorCode` after each validator that a client acts on. It applies to the last validator before it, not to the whole chain. Use the format of API-04 (`order.lines_too_many`).\n10. Set `RuleLevelCascadeMode = CascadeMode.Stop` in the constructor when a later check needs an earlier one (`NotEmpty`, then `Matches`, then `MustAsync`). It stops a second message and a null access in `Must`.\n11. Do not set `ClassLevelCascadeMode = CascadeMode.Stop`. It stops the whole validator after the first rule that fails, not each field. The client then gets one field error at a time (tested).\n12. Compose with `RuleForEach(x => x.Lines).SetValidator(lineValidator)` and the child validator from the constructor. FluentValidation 12.0 removed `InjectValidator` (CS1061).\n13. `SetValidator` skips a null item or child. When the value is required, put `.NotNull().WithErrorCode(...)` before `SetValidator`, else the handler throws. Null can also be a valid value, for example an optional field on an update that keeps the current value. Then `SetValidator` without `NotNull()` is correct. Do not flag it. With `CascadeMode.Stop`, a `RuleForEach` stops at the first bad item and does not check the other items. Add `.Cascade(CascadeMode.Continue)` to that rule when the client needs an error for each item (tested).\n14. Validate the shape of the input: required, length, range, format, and cross-field rules inside one request. Keep state rules in the domain, for example \"only a placed order can ship\". Keep uniqueness in a unique index with a 409. A validator runs only on the paths that call it. Two requests can pass the same check at the same time.\n15. Read limits from the options class that holds them (`IOptions\u003CT>` in the validator constructor). Do not copy a number into a second place. When a request names a limit that differs from the option, ask which one wins.\n16. Write two validators for two contracts. Do not use rule sets for it: they hide which rules run, and they pass into child validators.\n\nRule examples and the 12.0 removals: `references\u002Fvalidators.md`.\n\n### Tests\n\n17. Test the real validator with `TestValidateAsync` (valid and invalid case per rule, and the code). Use `InlineValidator\u003CT>` when a consumer test needs a validator that fails. Do not mock `IValidator\u003CT>`: the mock hides a missing registration and a sync call.\n\nTest examples: `references\u002Ftesting.md`.\n\n## Never write\n\n| Wrong | Correct |\n|-------|---------|\n| `AddFluentValidationAutoValidation()`, `AddMvc().AddFluentValidation(...)` | `AddValidatorsFromAssemblyContaining\u003CT>()` and an endpoint filter |\n| `using FluentValidation.DependencyInjectionExtensions;` | `using FluentValidation;` |\n| `internal sealed class CreateOrderValidator` with a default scan | `public sealed class`, or `includeInternalTypes: true` |\n| `AddValidatorsFromAssemblyContaining\u003CT>(ServiceLifetime.Singleton)` with a scoped dependency | `AddValidatorsFromAssemblyContaining\u003CT>()` |\n| `var result = validator.Validate(request);` in an endpoint or filter | `var result = await validator.ValidateAsync(request, ct);` |\n| `context.GetArgument\u003CT>(0)` passed to the validator as is | `context.Arguments.OfType\u003CT>().FirstOrDefault() is not { } argument` and a 400 |\n| `CascadeMode = CascadeMode.StopOnFirstFailure;` | `RuleLevelCascadeMode = CascadeMode.Stop;` |\n| `ClassLevelCascadeMode = CascadeMode.Stop;` to get one message for each field | `RuleLevelCascadeMode = CascadeMode.Stop;` (rule 11) |\n| `RuleForEach(x => x.Lines).SetValidator(lineValidator)` when an item can be null | `RuleForEach(x => x.Lines).NotNull().WithErrorCode(\"order.line_required\").SetValidator(lineValidator)` |\n| `RuleFor(x => x.Address).InjectValidator();` | Inject `IValidator\u003CAddress>` and call `SetValidator(addressValidator)` |\n| `Transform(x => x.Name, n => n.Trim())` | Project the value in the rule expression or in the request mapping |\n| `.NotEmpty().MaximumLength(32).WithErrorCode(\"sku_invalid\")` for both checks | `.NotEmpty().WithErrorCode(\"order.sku_required\").MaximumLength(32).WithErrorCode(\"order.sku_too_long\")` |\n| `TypedResults.ValidationProblem(result.ToDictionary())` when the client reads codes | The same plus the `code` and `errorCodes` extensions (API-20) |\n| `result.Errors.GroupBy(e => e.PropertyName).ToDictionary(..., e.ErrorMessage ...)` | `result.ToDictionary()` |\n| `[Required]` on the record and a validator for the same field | One of the two (rule 7) |\n| `new Mock\u003CIValidator\u003CCreateOrder>>()`, `Substitute.For\u003CIValidator\u003C...>>()` | `new CreateOrderValidator(...)` or `new InlineValidator\u003CCreateOrder>()` |\n| `ShouldHaveAnyValidationError()` | `ShouldHaveValidationErrors()` (12.x) |\n| `MustAsync(EmailNotTakenAsync)` as the only guard | A unique index, catch the violation, return 409 |\n\n## Check\n\n1. Build with the analyzers. Pass: 0 warnings and 0 errors. The 12.0 removals fail here (CS0117, CS0118, CS0103, CS1061).\n\n   ```\n   dotnet build -warnaserror\n   ```\n\n2. Find deprecated packages. Pass: no `FluentValidation.AspNetCore`.\n\n   ```\n   dotnet list package --deprecated\n   ```\n\n3. Run the rule check of this skill. Pass: `stackcheck: 0 errors`. In an existing project, add `--changed \u003Cbase branch>`.\n\n   ```\n   python3 \u003Cskill folder>\u002Fscripts\u002Fstackcheck.py --root \u003Crepo>\n   ```\n\n4. Run the tests. Pass: all green. Each rule has a `TestValidateAsync` test (valid and invalid, with the code). Each endpoint has one HTTP test that asserts the 400 and its codes.\n\n   ```\n   dotnet test\n   ```\n\n## Review checklist\n\nThe full list is in `references\u002Freview-checklist.md`.\n\n1. No `FluentValidation.AspNetCore`, no `AddFluentValidation*`. tool (FV-PKG-ASPNETCORE, FV-AUTOVALIDATION)\n2. Each call is `ValidateAsync` with the token. tool (FV-SYNC-VALIDATE)\n3. A filter checks the argument for null before the call. judge\n4. Validators are `public`, or the scan has `includeInternalTypes: true`. judge\n5. The lifetime is the default, or no validator takes a scoped service. tool (FV-SINGLETON) and judge\n6. One library per request type: no DataAnnotations and no `AddValidation` filter next to a validator. judge\n7. Each rule that a client acts on has its own `WithErrorCode`. The codes reach the response (API-20). tool (FV-MANUAL-DICTIONARY) and judge\n8. `RuleLevelCascadeMode = CascadeMode.Stop` where a check needs an earlier one. No `ClassLevelCascadeMode = CascadeMode.Stop`. tool (FV-CASCADE-DEPENDENT, FV-CLASS-CASCADE-STOP)\n9. Child validators come in through the constructor and `SetValidator`. A `RuleForEach` with items that can be null has `NotNull()`. tool (CS1061 for `InjectValidator`) and judge\n10. No state rule or uniqueness check as the only guard in a validator. judge\n11. Limits come from the options class, not from a second literal. judge\n12. Tests use the real validator or `InlineValidator\u003CT>`, not a mock. tool (FV-MOCK-VALIDATOR)\n13. The endpoint documents its 400 (`ProducesValidationProblem`, `dev-stack:aspnetcore-openapi`). judge\n\n## Existing code\n\nStack rule 3 applies. For this skill, check these defects in the existing code that the change touches:\n\n- A sync `Validate` call on a validator that gets a `MustAsync` rule, also in an import or a worker without an HTTP test (rule 5).\n- A filter without a null check, or that returns `ToDictionary()` without the codes (rules 6 and 8).\n- DataAnnotations on a type that gets a validator while `AddValidation()` is on (rule 7).\n- One `WithErrorCode` after a chain of validators (rule 9), and a limit that the handler checks a second time (rule 15).\n\n## Report\n\nEnd with the report of stack rule 8 (`references\u002Fstack-rules.md`). Output text follows `references\u002Flanguage.md`.\n\nAfter a change to an endpoint, add a table of the error codes below the \"Changes\" table. Give each code that a client can get from the endpoint, with its field (the property path, for example `Lines[0].Sku`) and the HTTP status. Also give where the code is in the response (the `errorCodes` extension, decision API-20). Include the existing codes that the endpoint keeps. The client team builds on this list.\n\n## References\n\n- `references\u002Fvalidators.md`: read when you write a validator, a child or collection rule, an async rule, or upgrade from 11.x.\n- `references\u002Fcall-sites.md`: read when you call a validator from an endpoint filter, a controller, or a worker, or shape the error response.\n- `references\u002Ftesting.md`: read before you write a validator test or an endpoint test that involves validation.\n- `references\u002Fdecisions.md`: read when new code needs decision API-08 or API-20.\n- `references\u002Freview-checklist.md`: read when you review a change.\n- `references\u002Fsources.md`: the primary sources and the date of each check.\n- `references\u002Fstack-rules.md`: the common rules of each dev-stack skill.\n- `references\u002Flanguage.md`: the rules for text output.\n- `scripts\u002Fstackcheck.py`: the rule check of this skill.\n",{"name":5,"metadata":23,"description":7},{"verified":24,"versions":25},"2026-10-27","FluentValidation 12.2.0 and FluentValidation.DependencyInjectionExtensions 12.2.0 (net8.0 and later), .NET 10 (SDK 10.0.403)","main","c247fa77bdea99449b9df09f93d92a35fed91874","plugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation","https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills","https:\u002F\u002Fgithub.com\u002FCharmedme","2026-11-13 14:41:21",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add Charmedme\u002Fmaikelsoft-skills --skill fluentvalidation",{"tool":38,"command":39},"bunx","bunx skills add Charmedme\u002Fmaikelsoft-skills --skill fluentvalidation",{"tool":41,"command":42},"pnpm","pnpm dlx skills add Charmedme\u002Fmaikelsoft-skills --skill fluentvalidation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002FSKILL.md",true,[46,52,56,60,64,68,72,76,80,84,90,94],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"references\u002Fcall-sites.md","REFERENCE","参考文档",7108,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Freferences\u002Fcall-sites.md",{"path":53,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":54,"sourceHtmlUrl":55},"references\u002Fdecisions.md",2948,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Freferences\u002Fdecisions.md",{"path":57,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":58,"sourceHtmlUrl":59},"references\u002Flanguage.md",4840,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Freferences\u002Flanguage.md",{"path":61,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":62,"sourceHtmlUrl":63},"references\u002Freview-checklist.md",3606,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Freferences\u002Freview-checklist.md",{"path":65,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":66,"sourceHtmlUrl":67},"references\u002Fsources.md",5313,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Freferences\u002Fsources.md",{"path":69,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Fstack-rules.md",7772,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Freferences\u002Fstack-rules.md",{"path":73,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":74,"sourceHtmlUrl":75},"references\u002Ftesting.md",4098,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Freferences\u002Ftesting.md",{"path":77,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":78,"sourceHtmlUrl":79},"references\u002Fvalidators.md",8422,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Freferences\u002Fvalidators.md",{"path":81,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":82,"sourceHtmlUrl":83},"rules.json",7819,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Frules.json",{"path":85,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":88,"sourceHtmlUrl":89},"scripts\u002Fconvert.py","SCRIPT","脚本",2928,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Fscripts\u002Fconvert.py",{"path":91,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":92,"sourceHtmlUrl":93},"scripts\u002Fdoccheck.py",29463,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Fscripts\u002Fdoccheck.py",{"path":95,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":96,"sourceHtmlUrl":97},"scripts\u002Fstackcheck.py",12200,"https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fdev-stack\u002Fskills\u002Ffluentvalidation\u002Fscripts\u002Fstackcheck.py",[99,106,113,120,127,134],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":18},"01M7EA9S53810TTZTXYDGBWXHY","web-accessibility","Web accessibility to WCAG 2.2 AA - a checklist for the design, the tool checks (axe-core, the Tab walk, reduced motion), and the manual checks that no tool does (screen reader, zoom, status messages) - with the EAA and EN 301 549 status. Use when a design, mockup, or built feature must be checked for accessibility, when a review must cover keyboard and screen reader use, when the user asks about focus, a focus trap, contrast, or a screen reader on a page, or when the user asks which accessibility rules apply.","https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fux-design\u002Fskills\u002Fweb-accessibility\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":18},"01M7EA9MGJ7ESKQ7WE2Z96858T","ux-states","State inventory for each screen - default, empty, loading, partial, error, success, disabled, overflow, offline, and the business states (no permission, stale data, locked by another user, waiting on an external system, bulk result with failures, read only) - with what the user sees, can do, and how the user recovers. Use when a screen or flow needs its states designed or checked, or when a design shows only the happy path.","https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fux-design\u002Fskills\u002Fux-states\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":18},"01M7EA9FHYR0C26BHNQF7AZT4Q","ux-setup","Set up a project for UX work - finds the design tools, the design-system source, the brand files, the languages, and the run command, asks the human one round of questions, and writes the \"## Design\" section of .claude\u002Frules\u002Fdelivery.md that the ux-design commands and the ux-designer agent read. Moves an older \"## Design\" section out of CLAUDE.md. Use when \u002Fsetup, \u002Fux-design, or \u002Fux-review needs the design facts, when the ux-designer agent returns NEEDS_HUMAN because the \"## Design\" section is missing, or when the user wants to set up or change the design tools of a project.","https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fux-design\u002Fskills\u002Fux-setup\u002FSKILL.md",[],[],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":18},"01M7EA99DQDFVJQBJNYDJQC643","ux-review","UX review of a built feature against its approved design - Playwright walks each flow and state at 390, 820, and 1440 px, axe-core and the tell checks run on each state, and each heuristic gets a verdict - with findings by owner, severity, and origin, and a verdict in ux-review.md in the work folder of the item. Use when a built feature or screen must be checked against its design, mockups, or prototype, in each state or at each screen size, when built screens need findings by severity, when the build of an item with a UX design is done, or when existing screens need a UX audit.","https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fux-design\u002Fskills\u002Fux-review\u002FSKILL.md",[],[],{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":18},"01M7EA95YPJQQ1YDW5HS0RVAN2","ux-prototype","Clickable prototype of a designed story in the proto-shell standard, with variants for an A\u002FB test, all states in scope, three sizes, and a test plan with tasks. Use when a design or mockups exist and the team must test the flow or compare variants with users before the build.","https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fux-design\u002Fskills\u002Fux-prototype\u002FSKILL.md",[],[],{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":18},"01M7EA91SKA2RNFGW9VDG9JFW7","ux-practice","The method of the ux-designer agent for the UX design of a story, a feature, or a screen - Double Diamond phases, a design spec with a source for each decision, the UX decision log, evidence tags, severity, and the modes light, full, and new-direction. Preloaded by the ux-designer agent. Use when the ux-designer agent or another UX skill names this method. For the design of an item, a person starts ux-design:ux-design.","https:\u002F\u002Fgithub.com\u002FCharmedme\u002Fmaikelsoft-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fux-design\u002Fskills\u002Fux-practice\u002FSKILL.md",[],[]]