Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mongoose for Application Development

You're reading from  Mongoose for Application Development

Product type Book
Published in Aug 2013
Publisher Packt
ISBN-13 9781782168195
Pages 142 pages
Edition 1st Edition
Languages
Author (1):
Simon Holmes Simon Holmes
Profile icon Simon Holmes

Table of Contents (18) Chapters

Mongoose for Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Introducing Mongoose to the Technology Stack 2. Establishing a Database Connection 3. Schemas and Models 4. Interacting with Data – an Introduction 5. Interacting with Data – Creation 6. Interacting with Data – Reading, Querying, and Finding 7. Interacting with Data – Updating 8. Interacting with Data – Deleting 9. Validating Data 10. Complex Schemas 11. Plugins – Re-using Code Index

Adding validation to our project


Now that we've done the theory, why not see if you can add some validation to our MongoosePM application? We're not going to walk through this here, but do try it out yourself. If you're impatient you can of course just download the source code from Packt's website. The code contains various ways of achieving the same validation, commented out for reference.

For users, try adding the following validations:

  • Name: Make this required, and with a minimum length of five characters

  • Email: Make this required, unique, and only allow a valid e-mail address

    Tip

    Use a regular expression.

For projects, have a go at this:

  • projectName: Make this required, with a minimum length of five characters, and only accept unique values for each user

    Tip

    Use an asynchronous validator.

To get the validation working for both users and projects, you will need to:

  • Update the schemas to include validators

  • Update the create/edit controllers to interpret the error messages

  • Save the submitted data...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}