Create utility validation function.
Don't use state for validation in most places as validation can be done in-place.