Form Validation in Elm: Course Overview

    Enrico BuonannoEnrico Buonanno

    This course will introduce you to common form validation solutions in Elm. You will see how to validate an email string, strong passwords, and make the confirmation password matches.

    The UI simple and logic for validation will be kept straight forward so you can focus on managing the state of the form in relation to user interaction.

    You will also see a few solid approaches to solving complex problems in a functional style. We will compose validation rules together (Kleisli composition) and combine several validations in a form (applicatives).



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson


    Instructor: 00:01 This course, as the title suggests, teaches you to do form validation in Elm. Naturally, we look at some common validation scenarios, such as validating email addresses, numbers, validating that a password is strong enough, that two passwords match, and so on.

    00:18 We'll keep the UI as simple as possible, and logic for each validation is also straightforward. This allows us to concentrate on the more challenging issues, namely managing the state of the form in relation with the user interaction.

    00:33 On another level, this course also teaches you how to approach complex problems in a functional style. We spend a good portion of the time to find the best way to model validation, taking advantage of Elm's static type system.

    00:47 We also use several classic functional techniques. For example, this piece of code shows you how to compose two validation rules -- that the field should not be empty and that it should be a valid email address. This way of combing two rules is an instance of a wider technique called Kleisli composition.

    01:05 This other snippet shows you how to combine the validation of several fields on a form and only submit the form if all fields are valid. Here, this is achieved using another functional technique, that of applicatives.

    01:19 I definitely recommend this course if you're writing forms in Elm, but I also recommend it if you're more generally interested in Elm and in functional programming.