Every line of 'joi date validation' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
9 export default function dateValidation(dateToValidate, options) { 10 return moment(dateToValidate, options).isValid(); 11 }
182 validateTypeDate(value, key) { 183 if(value instanceof Date) return true; 184 this.setError(key, this.messages.validateDate(key)); 185 return false; 186 }
42 function validateDate(value, meta) { 43 if (value && !utc(value).isValid()) 44 return {[meta._id]: `${meta.label} must be a valid date`} 45 }
79 validatesDate: function validatesDate() { 80 Array.from(arguments).forEach(function (name) { 81 this.validate(name, function () { 82 this.validateDate(name); 83 }); 84 }, this); 85 },
388 validateTypeDate(value, key, index) { 389 if (value instanceof Date) return true; 390 const { label } = this.getField(key); 391 this.setError(key, this.messages.validateDate(label || key), index); 392 return false; 393 }
6 validate(data) { 7 if (!data) { 8 return; 9 } 10 11 assert(lodash.isString(data)); 12 assert(moment(data, 'YYYY-MM-DD').isValid()); 13 }
258 validateJoi(entityData: any): any { 259 if (!this.isJoi) { 260 return { 261 error: new ValidationError(ERROR_CODES.ERR_GENERIC, 'Schema does not have a joi configuration object'), 262 value: entityData, 263 }; 264 } 265 return this.joiSchema!.validate(entityData, (this.options.joi as JoiConfig).options || {}); 266 }
80 validate(parts) { 81 let month = parseInt(parts.month, 10); 82 let day = parseInt(parts.day, 10); 83 let year = parts.year; 84 month = (month >= 0 && month <= 11) ? month : null; 85 year = (year && year.match(/^\d{4}$/)) ? parseInt(year, 10) : null; 86 day = (day >= 0 && day <= 31) ? day : null; 87 if (month === null || day === null || year === null) return null; 88 return { month, year, day }; 89 }
18 static ruleName() { 19 return 'date'; 20 }