Skip to content

Validation: function and class validators #3377

Backlog

Description

@david-driscoll

Part of #3374. Spec: docs/design/validation.md. Pull request: #3382.

  • Discovery by shape: static void Validate(IValidationBuilder<T> v, ...dependencies) and partial classes implementing IValidator<T>; several per type merge.
  • The builder DSL rewritten at build time: Ensure, EnsureEach, built-in rules, Must/MustAsync, When/Unless, WithMessage/WithCode/WithSeverity/WithName, StopOnFailure, ValidateWith, Include; custom rules through [ValidationRule].
  • Dependencies become constructor parameters of the generated validator.
  • Synchronous unless a rule is async; synchronous use of an async validator is a build error with a code fix.
  • A diagnostic for every statement the generator refuses in a Validate body.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions