✅ Difference between [DataType(DataType.EmailAddress)] and [EmailAddress] data annotations?
Can anyone let me know what's the difference between [DataType(DataType.EmailAddress)] and [EmailAddress] data annotations? Using the former alone is not validating the email field so what's it's purpose? Thanks
4 Replies
the former is mainly for formatting purposes and will not trigger server side validation
only
[EmailAddress]
will trigger server side model validationcould you pls elaborate what do you mean by formatting?
got it, it affects the format displayed in swagger ui
![](https://utfs.io/f/7e2f8d92-d0b4-46fe-a40e-801cb079a5b7-1nq2cb.png)
Closed!