유효한 URL을 입력하지 않으면 스키마가 실패하더라도 오류가 표시되지 않습니다.몽구스 검사기가 isURL 유효성 확인하지 않음
프런트 엔드의 데이터가 올바르게 전송되고 있는지 확인할 수 있습니다. 그것은 경로를 통해 몽구스에게 전달되고 있습니다 (아래 참조).
Hosts.Create (req.body, func ...) 함수의 콜백에 Err이 없습니다.
이것은 스키마입니다. 유효성 검사기 : [validators.isURL()]이 (가) 메시지를 생성하지 않습니다.
var HostSchema = new Schema({
domain: {
type: String,
required: [ true, 'A Domain is required' ],
// This is the broken validator
validator: [ validators.isURL({message: 'Must be a Valid URL', protocols: ['http','https','ftp'], require_tld: true, require_protocol: true}) ]
},
pkg: {
type: String,
required: [ true, 'Hosting Package is required' ]
},
ssl: { type: Boolean, required: true },
maint: { type: Boolean, required: true },
...
});
내 경로 파일 :
// Process Add Cx
hosting.post('/add', function(req, res, next) {
// If No Request data.
if (req.body.constructor === Object && Object.keys(req.body).length === 0) {
... Send View if no form data ...
} else { // Proccess Data
// Create new User
Hosts.create(req.body, function(err, host) {
if (err) return res.json({success: false, message: Hosts.MongoErrors(err)});
// If everything was sucessful! Yay!
res.json({success: true, message: 'Host Successfully Saved!'});
});
}
하하하, 감사합니다! 나는 이것이 다른 누군가를 도울 것이라고 확신합니다. 문서화가 너무 명확하지는 않습니다. –
'value'는 어디에서 오는가? –