maxlength depending on nodetype (contenttype)
You could use hook_node_presave to set the maximum length of a fields value before the node is saved or inserted in the database.

For example, to force a field field_dummy for a node of type article to a maximum of 50 characters you could do like this:

function HOOK_node_presave($node){
  if($node-&gt;type == 'article'):
    // force the field to max 50 characters
    $node-&gt;field_dummy[$node-&gt;language][0]['value'] = 
       substr($node-&gt;field_dummy[$node-&gt;language][0]['value'], 0, 50);
  endif;
}