课程: JavaScript: Five Advanced Challenges and Concepts

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Advanced solution: Create a data validation system

Advanced solution: Create a data validation system - JavaScript教程

课程: JavaScript: Five Advanced Challenges and Concepts

Advanced solution: Create a data validation system

(upbeat music) - [Instructor] A common use of singletons and proxy objects is for system functionality like data validation. That's the focus of this challenge. The functionality as we get started is split between the answer code and the test code. In the test code, you'll find a bookings array of objects describing different bookings. This array is used below by a script that maps through each of the booking objects and tries to create a new booking from it. For each item in the array, a new instance of the booking class is created. A proxy is created for that booking that modifies it by some booking validation rules. And finally, the system returns messages depending on whether the validations pass, fail, or there is some other error. In the answer code, there are the beginnings of the functionality we need. At the top, you find an array of error messages that will be used for the validation. Next, there's the…

内容