refactored validator into separate package