Validation of data in a servant server

I've been playing around with adding more validation of data received by an HTTP endpoint in a servant server. Defining a type with a FromJSON instance is very easy, just derive a Generic instance and it just works. Here's a simple example data Person = Person { name :: Text , age :: Int , occupation :: Occupation } deriving (Generic, Show) deriving (FromJSON, ToJSON) via (Generically Person) data…