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

Did I find a problem or did I not understand correctly? (Validation with Annotations) #126

Open
fplagamba opened this issue Jul 4, 2023 · 0 comments

Comments

@fplagamba
Copy link

Hi Community,
I am testing CommunityToolkit.mvvm and I have some problems ...
#1
I have a property of type string that must contain an EmailAddrtes

This is the property definition:
[ObservableProperty]
[NotifyDataErrorInfo]
[Required]
[EmailAddress]
public string? _mailAddress;

This is working perfectly

But I also have a string property that should contain a date, but I can't get the correct validation.

This is the definition:
[ObservableProperty]
[NotifyDataErrorInfo]
[Required]
[DataType(DataType.DateTime)] // Doesn't work
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] // Doesn't work
public string? _birthDate2;

I think the problem is in the annotation:
[DataType(DataType.DateTime)]

But what do I have to write to get the correct validation?

#2
In addition to validation, I would also like to get the required formatting,
but that doesn't seem to work either.

#3
A general problem, not specifically of the toolkit.
When I search for something on GitHub / NuGet I find dozens of occurrences of packages of similar name...
Wouldn't it be appropriate to assign a unique identifier so that the poor programmer knows which one to choose?
Thank you for your attention.

Best regards

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

No branches or pull requests

1 participant