Create (Async)

Post


Back to List

Post Validation rules

To help with testing the Post data class, i.e. the one that is linked to the database, has extra rules over the DetailPostDto. This means that more tests are done when the database is updated, which are then caught by SaveChanges and sent back as errors.

Rules in both DetailPostDto and Post
Property Validation rule Where shown? Where Checked*
Title Must have between 2 and 128 characters in it By property Browser,MVC,EF
Title Must not contain HTML symbols, e.g. <, > Exception MVC
Content Cannot be empty By property Browser,MVC,EF
Content Must not contain HTML symbols, e.g. <, > Exception MVC
Blog (Author) Must have a blogger assigned to the post By property DTO,EF
Tags Must have at least one tag assigned to the Post By property DTO,EF
Rules only in Post

Note that these strange rules have been added to allow testing of different error conditions

Property Validation rule Where shown? Where Checked*
Title Must not include an exclamation mark, i.e '!' By property EF
Title Must not end with a question mark, i.e '?' By property EF
Content A sentence must not end with the following words:
' sheep.', ' lamb.', ' cow.' or ' calf.'
At top EF

Note*: The 'Where Checked' terms are

The test for HTML symbols is done by MVC and throws an exception, which in the release version goes to the default error page.