add dynamic length validation