Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve NotNull/NotEmpty validator messages #1126

Closed
oskogstad opened this issue Sep 13, 2024 · 0 comments
Closed

Improve NotNull/NotEmpty validator messages #1126

oskogstad opened this issue Sep 13, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@oskogstad
Copy link
Collaborator

oskogstad commented Sep 13, 2024

Check for use of

  • Null
  • Empty
  • NotNull
  • NotEmpty
    with When( ... ) clauses, inn all validators

Explained here:
#1110 (comment)

Instead of:

        RuleFor(x => x.TransmissionId)
            .Null()
            .When(x => x.ActivityType == DialogActivityType.Values.DialogOpened);

make it:

        RuleFor(x => x.TransmissionId)
            .Null()
            .When(x => x.ActivityType == DialogActivityType.Values.DialogOpened)
            .WithMessage($"{{PropertyName}} must be empty when {nameof(NotificationConditionQuery.ActivityType)} is {DialogActivityType.Values.DialogOpened}.");
@oskogstad oskogstad added enhancement New feature or request good first issue Good for newcomers labels Sep 13, 2024
@elsand elsand moved this from Backlog to Ready in Dialogporten / Arbeidsflate Sep 15, 2024
@Fargekritt Fargekritt self-assigned this Sep 16, 2024
Fargekritt added a commit that referenced this issue Sep 16, 2024
## Description

Improved validator messages to give error messages with null + when
checks.

## Related Issue(s)

[#1126](#1126)

## Verification

- [x] **Your** code builds clean without any errors or warnings
- [x] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)


Co-authored-by: Amund Myrbostad <amund.myrbostad@digdir.no>
@elsand elsand closed this as completed Oct 8, 2024
@github-project-automation github-project-automation bot moved this from Testing / Design QA to Done in Dialogporten / Arbeidsflate Oct 8, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Good first issues Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Archived in project
Status: Done
Development

No branches or pull requests

3 participants