C
C#2y ago
riazuezra

✅ 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
Patrick
Patrick2y ago
the former is mainly for formatting purposes and will not trigger server side validation only [EmailAddress] will trigger server side model validation
riazuezra
riazuezraOP2y ago
could you pls elaborate what do you mean by formatting?
riazuezra
riazuezraOP2y ago
got it, it affects the format displayed in swagger ui
Accord
Accord2y ago
Closed!
Want results from more Discord servers?
Add your server