add maxlength minlength fix so that value is read in validator

This change moves the min and max length attribute value read within the validator rather than outside. This is useful if you need to dynamically change the min and max length values later (i.e. the values are not baked).