Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mongoose validate array of references required

const questionSchema = new mongoose.Schema({
  question: {
      type: String,
      required: [true, 'Question Required'],
      trim: true
  },
  options: {
    type: [{
        optionNo: Number,
        optionValue:{
            type: String,
            required: [true,'Option required'],
            trim: true
        }
    }],
    validate: [(val) -> val.length > 1, 'Must have minimum two options']
  }
});
Comment

mongoose validate array of references required

questionSchema.path('options')
    .validate((val) -> val.length > 1, 'Must have minimum two options');
Comment

PREVIOUS NEXT
Code Example
Javascript :: check if key in dictionary javascript 
Javascript :: reply nodejs terminal 
Javascript :: adding object into object 
Javascript :: dropzone alert 
Javascript :: setting a date range using yup on react date picker 
Javascript :: globalevariable reactjs 
Javascript :: /home/raj/Desktop/webProjects/node-shop-api/node_modules/whatwg-url/dist/encoding.js:2 const utf8Encoder = new TextEncoder(); ^ ReferenceError: TextEncoder is not defined 
Javascript :: Get mimeType in Javascript 
Javascript :: online regex generator based on string 
Javascript :: next js global layout 
Javascript :: nested while loop in javascript 
Javascript :: too many rerenders 
Javascript :: Access nested objects and arrays using string path 
Javascript :: example of post increment in js 
Javascript :: javascript random to abs 
Javascript :: Search products from an array by keywords in javascript 
Javascript :: jboss-ejb-client.propeties exampe de configuration 
Javascript :: how to retrieve get parameters from javascript 
Javascript :: Fabricjs configurations 
Javascript :: uniqSort 
Javascript :: jquery excel export 
Javascript :: tableexport npm 
Javascript :: moment iso string to zero 
Javascript :: how we can use pagination in angular material and spring boot 
Javascript :: Declaring Variables Shorthand javascript 
Javascript :: different way to for loop js 
Javascript :: javascript query corrector 
Javascript :: node parse markdown files with frontmatter 
Javascript :: minutes to seconds javascript 
Javascript :: axios with load more 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =