Join Justin Schwartzenberger for an in-depth discussion in this video Validation—custom, part of Angular 2 Essential Training (2016).
- [Voiceover] Alright, let's build a custom validator.…To build your own custom validators,…you need to create a function that will…receive a control object,…and that function needs to return null when valid…and return an object if invalid.…Let's build a year validator for the year field.…In the media-item-form.component.ts file,…we can create a method named year validator,…and give it a parameter named control.…Angular is going to pass in the control instance…for the control we put as custom validator on.…
The year field is optional, so the first…bit of logic we will add is to return null,…telling the validator that everything is valid.…When the string length of the control.value is zero,…if it makes it past that,…we wanna convert the value into a number.…So we can call parseInt on control.value…and capture it into a local variable named year,…and then we will set up a min and max year,…let's assume that 1900 to 2100 is the time frame…that media will have it to run…and then we will alt beyond other…things like vr or something.…
- What is Angular?
- Setting up an Angular template
- Creating a component
- Displaying data
- Working with events
- Using two-way data binding
- Creating a subcomponent
- Using the built-in HTTP module
- Using the built-in router module
Skill Level Intermediate
AngularJS and WordPress: Building a Single-Page Applicationwith Roy Sivan31m 52s Intermediate
Building a Mobile App with AngularJS 1 and Ionicwith Ray Villalobos3h 31m Intermediate
1. Architecture Overview
3. Directives and Pipes
5. Dependency Injection and Services
Next steps1m 20s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.