InDepth Knockout Validation

InDepth look at the Knockout Validation Library
Course info
Rating
(114)
Level
Intermediate
Updated
Sep 24, 2013
Duration
1h 18m
Table of contents
Getting Started
Basic Validation
Advanced Validation
Advanced Configuration
Description
Course info
Rating
(114)
Level
Intermediate
Updated
Sep 24, 2013
Duration
1h 18m
Description

The In-depth Knockout Validation course will show you how to use every nook and cranny of the Knockout Validation library. You will see not only how to setup basic validation, but learn how to create your own rules. We will even go over how to tweak the configuration of the library to meet your particular needs.

About the author
About the author

Derik Whittaker is a Software Architect who specializes in all things .Net who has been building enterprise systems for over 12 years and along the way has picked up a thing or two about building create killer systems. He is a 5 time C# MVP and blogs at http://devlicio.us.

More from the author
Introduction to Grunt
Intermediate
2h 13m
Jul 31, 2014
Knockout For the XAML Developer
Intermediate
2h 16m
Jun 28, 2013
Section Introduction Transcripts
Section Introduction Transcripts

Getting Started
Hello and welcome to Module 1 of InDepth Knockout Validation, I'm your host Derik Whittaker. This module will kick off our training of how to use a Knockout Validation library. We'll start by reviewing what Knockout Validation is and how it can be used. We'll then continue on and learn how to setup and configure our web projects in order to use knockout validation. By the end of this module you should have a better understanding about what Knockout Validation is and how it can be used. This module is setup to teach about Knockout Validation and how you should use as well has how to setup your environment in order to use the library. We'll end this module by doing a short demo to illustrate some of the power behind the library. The first thing we need to do is understand what the Knockout Validation is and why it's a library you'd want to use. Once we understand why we'd want to use this library, we'll need to learn how to download the bits and get rolling using it. To demonstrate this I'll use Visual Studio and we'll use the NuGet package manager to download and configure all of the libraries we're going to use. Once we have our environment setup we're ready to roll and I'll provide a short demo on how the library can be used to illustrate what's coming later throughout this course.

Basic Validation
Hello and welcome to module 2 of InDepth Knockout Validation, I'm your host Derik Whittaker. This module kicks off our training in how to use the Knockout Validation library. We will go from 0 to 60 in learning how to use the basics of Knockout Validation. The focus of this module will be two things, first learning how to setup our binding context in order to leverage the validation library. The second will be how to use many of the validators which are built into this library. This module is going to be broken into two parts, the first part will cover the basics needed to get Knockout Validation up and running and the second part will cover many of the built in validators. We will learn how to set up our binding context to hook into the validation library, we will also learn how to set up the validation at our first observable. The validation rule we will be using will be the required validator. The required validator does exactly as the name applies, it will require that the bound observable was populated with some data. Once we understand how to use the required validator, we'll spend some time looking at some of the built in validators. The next validator we'll learn is how to use the Min/Max Validator. This will ensure that our bound observable will not go below or above the value specified within our rule. The next two validators we will learn is the Equal/Not Equal Validator, these can be used to ensure that observable values either equal to or not equal to some other values specified in our rule. The third set of validators we will explore are the Min/Max Length Validators, these two validators are used to ensure that a string value does not dip below a specified minimum length or exceed a specified maximum length. The last validator we will explore is the Pattern Validator. This validator leverages the power of regular expressions and can be used to perform pattern match validation on any observable.

Advanced Validation
Hello and welcome to Module 3 of InDepth Knockout Validation, I'm your host Derik Whittaker. In this module we going to shift focus from learning how to use the basic built in validation abilities of the framework and learn how to extend the framework to meet our custom needs. This module is going to be separated into four pieces first we'll learn how to create our own custom validator. Having the ability to create a custom validator is critical as the basic built in validators will simply not satisfy all of our business needs. When learning to create our own custom validators we will learn how to create global rules, these are rules which can be applied to any observable as well as inline rules. Inline rules are only available to their attached observable and cannot be reused. Once we understand how to create our own custom rules, we'll move on to learn how to perform validations against Computed Observables. Computed Observables are a bit different than standard observables because they're not attached to any input fields. This means two things for us, first we must reference another observable inside of our validator in order to get the validator to evaluate as the data changes. And second if we wanted to display an error message to our user, we will have to manually add our markup to display our message. Next we'll learn how to Perform Conditional Validation on an observable. Having the ability to only have a validator fire based on some other value is very important because in building line of business applications they're going to be cases where you only care about the validation when a given piece of data is updated. Finally we'll end our module by learning how to perform validation by using the HTML5 Validation Attributes. These attributes mean we do not need to manually wire up our logic inside of our view model, but it does come with a cost, which is the solution will not work across all browsers or in all cases.

Advanced Configuration
Hello and welcome to Module 4 of InDepth Knockout Validation, I'm your host Derik Whittaker. In the previous modules we've focused all of our efforts on the validators and we've really not spent any time learning how to configure Knockout Validation. This is about to change because in this module we're going to learn about many of the advanced configuration options available to us when using Knockout Validation. We're going to start off this module by learning how to set up our view model to perform input validation when the view model is bound to our view. We want to do this because out of the box the validation does not fire until you dirty an element, but there will be cases where you'll want to inform your user of invalid fields as soon as the page loads. We will then move on to learn how we can change the styles applied to our validation messages. We will want to learn how we can change a base CSS style, which is applied to each validation message, we'll also learn that we can remove the validation messages altogether and instead apply a style to our bound input elements if we desire. After this we'll move on to learn how we can apply custom message templates to our validation messages before being shown to our user. We will want to learn how to do this because the default template simply shows our message and your business needs may require more than just a message. We'll also learn that we can suppress the message from being placed inline and move it into a validation group. Finally we'll end this module by learning how we can configure Knockout Validation on an element by element bases. Basically allowing us to change the way the validation message appear for each and every input field.