Most likely that code already existed server-side and was duplicated client-side. It's what usually happens since frontend code can't enforce invariants.
That means that any validation that you do client-side you need to repeat server-side. Any business logic that you have client-side you also need to repeat server-side.