Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Microsoft Code Contracts unsuitable for validating user input?

I've seen it written elsewhere on SO that while the Enterprise Library Validation Application Block is geared towards validating user inputs, Code Contracts are meant to prevent programmer errors. Would you support this opinion? Why?

like image 976
urig Avatar asked Feb 26 '23 08:02

urig


1 Answers

Yes.

Code contracts are meant to keep a strict programming interface, which only a developer can get right or wrong; a user shouldn't really be able to mess this up.

Validation is meant to validate the data; e.g. verifying data isn't null, or matches a regex.

like image 167
Jay Sullivan Avatar answered Apr 07 '23 01:04

Jay Sullivan