This is a simple web API built using Iron combined with ZIO JSON and ZIO HTTP.
It receives a user via a POST request to localhost/register.
Example request:
{
"name": "totore",
"password": "abc123",
"age": 18
}The passed fields must satisfy the following constraints:
- Name should be alphanumeric and have a length between 3 and 10
- Password should contain at least a letter, a digit and have a length between 6 and 20
- Age should be strictly positive
If an invalid value is passed, the response will look like this:
HTTP/1.1 400 Bad Request
Date: Wed, 23 Nov 2022 07:27:06 GMT
Connection: keep-alive
Content-Type: application/json
Content-Length: 133
{
"message": [
"Password must contain atleast a letter, a digit and have a length between 6 and 20"
]
}Use the following command to run the example:
mill examples.formZio.runNote: this command must be run in the Iron root directory.