Explorar o código

Allow null in validation, thereby removing the profile picture

sbkwgh %!s(int64=7) %!d(string=hai) anos
pai
achega
adadfbf1db
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      models/user.js

+ 2 - 2
models/user.js

@@ -68,10 +68,10 @@ module.exports = (sequelize, DataTypes) => {
 						throw new sequelize.ValidationError('password must be a string')
 					}
 				},
-				isValidBase64 (val) {
+				isValidBase64OrNull (val) {
 					let base64Regexp = /^data:image\/(png|jpeg|jpg|gif);base64,[A-Za-z0-9+\/=]+$/g
 
-					if(!val.match(base64Regexp)) {
+					if(!val.match(base64Regexp) && val !== null) {
 						throw new sequelize.ValidationError('image must be valid base64')
 					}
 				}