Skip to content

Allow a bare validator name in @validators; report missing arguments - #112

Merged
Kinflou merged 1 commit into
masterfrom
feat/bare-validator-names
Oct 18, 2026
Merged

Kinflou merged 1 commit into
masterfrom
feat/bare-validator-names

Conversation

@Kinflou

@Kinflou Kinflou commented Oct 18, 2026

Copy link
Copy Markdown
Member

@validators = [Positive] was a syntax error ("unrecognized or incomplete syntax"), so a validator with no properties had to be written Positive().

  • Grammar: an AnnotationCall's (...) is now optional (AnnotationCallArgs, the same shape as AnnotationAssignment). AnnotationCall::args() returns &[] for a bare name. Rendering stays canonical: [Positive()].
  • Missing arguments: a locally declared validator's properties without a default must be given, otherwise validation::missing-validator-argument (validator 'Range' is missing argument 'min'). Before this, only codegen caught it ("no value given, and it has no default"). A bare name that needs arguments now gets that error instead of a parse error.

Tests: the bare form freezes to a ValidatorRef with no args, alongside a call; a missing required argument is reported; one with a default may be left out.

`@validators = [Positive]` is now the same as `[Positive()]`: the call's
parentheses are optional. A property without a default that the call
doesn't give is now an error (`validator 'Range' is missing argument
'min'`) - previously only codegen noticed, and only when generating.
@Kinflou
Kinflou merged commit d396429 into master Oct 18, 2026
9 checks passed
@Kinflou
Kinflou deleted the feat/bare-validator-names branch October 18, 2026 14:08
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.

1 participant