adds length validation.