Creating our User with Lifting

Learn how to create a user for our User Registration project.

We'll cover the following

Overview

Let’s assume our data passed the checks mentioned in the previous lesson and is deemed valid. We should start building our User domain object now. For the first and last name, this is pretty easy. Use the iso we saw earlier and wrap our string in it. For gender, we use one of the various ways of asserting that the sex string is a valid Gender because we (but not the compiler) now know it’s OK. Age and country pose some difficulties. If we want to get a PositiveInteger for age, fp-ts will give us back an Option. Plus, we didn’t do any checks for the region. What if it happens to be invalid? Exploring this topic, we add the following functions to our domain:

Get hands-on with 1200+ tech skills courses.