Added validation of range and length constraints.