Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At risk of not answering the question at all...</p> <p>You seem to have a business rule that says "this particular field should contain a maximum of N characters."</p> <p>I would argue that both the database column's size and the textbox maximum length are separate consequences of this business rule. Fixing one from the other confuses correlation with causation.</p> <p>In addition, enforcing this business rule by examining the maximum length of the database column has other effects:</p> <ul> <li><p>you'll hit the database every time for what could otherwise be an in-memory validation operation;</p></li> <li><p>if your business rule changes slightly (eg: N goes from 100 to 80 characters) then you need a schema-level change;</p></li> <li><p>some databases working with variable-length character encoding like UTF8 only fuzzily define how many characters even fit in a given column;</p></li> <li><p>more broadly, you're coupling the business rule to an implementation artifact - what if you later decide to use an object database?</p></li> </ul> <p>I'm not suggesting that you don't sensibly size your database columns (you should), only that you decouple the business rule from the database implementation. If you can get away with a simple fixed-length-check in the application code, I would suggest that. </p> <p><strong>Edit</strong> having read your question a little more carefully, for your text field maximum lengths you need N ahead of validation. Nonetheless, this is still a business rule - can you write a <code>MaximumLength</code> attribute for your field accessors and interrogate that? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload