factor out validate method into util script