Usage

In this section, we'll dive deeper into the usage of modddels.

Let's create an instance of our modddel :

// NB : In this section's examples, the types of the variables is specified only
// for the sake of showing their types to you. You don't need to do so.

final Username username = Username(value: 'dash');

Here are a few utilities you can use :

// You can quickly verify if a modddel is valid using [isValid]
bool isValid = username.isValid;

// You can convert the modddel to an Either using [toEither] or [toBroadEither]
Either<InvalidUsername, ValidUsername> either = username.toEither;

Either<List<Failure>, ValidUsername> broadEither = username.toBroadEither;

You can explore more utilities in the next subpages :