Type Predicates and Assertion Functions 6 exercises
Problem

Combining Brands and Type Predicates

Here is an isValidPassword function that makes use of a PasswordValues interface. We also have a Valid branded type.


type Valid<T> = Brand<T, "Valid">;
interface PasswordValues {
password: string;
confirmPassword: string;
}
const isValidPassword = (values: PasswordValues)

Loading exercise

Transcript

0:00 In this exercise, we're going to combine the type predicates that we've seen before and the brands that we've seen before as well. We have a similar setup to an exercise we've done before, which is we have isValidPassword, createUserOnApi.

0:15 We're looking to basically check that when we call the submit handler that we're basically saying, createUserOnApi, it's going to error because these password values do not equal these valid password values. We're going to use isValidPassword to basically be the decider.

0:33 It's going to say, once we've, it's going to return a Boolean to determine whether the values are valid or not. This is your job. You're going to need to change this function in some way to give it an annotation to make this logic work. Good luck.