how to define custom types with validators