O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Validation

Mongoose comes with several built-in validators. Some validators are present in all data types and some are exclusive for a data type. For example, a String field will have the min and max validators but a Boolean type will not.

Let's add some validations to our Team schema. Open the mongoose-connection.js file and apply the following changes:

...const TeamSchema = new mongoose.Schema({  name: {    type: String,    min: 3,    max: 100,    required: true,    unique: true  },  ranking: {    type: Number,    min: 1  },  captain: {    type: String,    required: true  },  Trainer: {    type: String,    required: true  },  confederation: {    type: String,    required: true,    uppercase: true  }})

Now, our schema looks more professional and will help us validate the data before it is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required