Skip to content

Blazor server Annotation Validators C# Error Message #45638

@bjm3819

Description

@bjm3819

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm using data annotations in a blazor server application. Were trying to prevent users from entering certain special characters.
The problem is it appears the error message were including is causing something to choke, throw a null exception.
T1134400_WithoutDevExpress.zip

Data.annotation.test.without.DevExpress.mp4

`
[RegularExpression(@"^[a-zA-Z0-9(){}|\/,.:;' -]*$", ErrorMessage = "Only Alpha numeric and the following special characters allowed: (){}|\/,.:;'-")]
public string PropertyWithRegXMessageCausingException { get; set; }

`

Expected Behavior

upon entering = in the input Id get a validation message "Only Alpha numeric and the following special characters allowed: ()_{}|\/,.:;'-"

Steps To Reproduce

steps to recreate
using my app attached run the app, click 'Data annotation test' from navigation menu.
Then enter = in the lower input box. ("note the red border noting that the input is invalid")
Now enter = in the upper input box. ( you'll get a unhandled exception )
reference my DataAnnotionsTest.cs class and DataAnnotateTest.razor file for source.

refer to original complaint to third party control library whom said the issue was not with their controls. ref

Exceptions (if any)

No response

.NET Version

.NET 6.0

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-blazor-server

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions