How to generate a property with a validation method using the [ObservableProperty] attribute?

Open
#457 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp
Domain
documentation

Research direction

Start by reviewing the existing documentation for the [ObservableProperty] attribute and its validation guidance. Check whether an example or explanation is missing; done means the supported approach is documented clearly enough to answer the question without requiring users to write the full property manually.

Written by the indexing model from the issue text.

Description

Pri3

Hi,everyone!
Here's my question:
When I use the [ObservableProperty] attribute,
it generates a regular property without a validation method. If I need to validate this property,
I have to write out the entire property, like this. Is there a better way to implement it?

image

Dominant language
No language data
Stars
168
Forks
134
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MicrosoftDocs/CommunityToolkit

All issues in MicrosoftDocs/CommunityToolkit

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.