mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-05 10:28:27 +02:00
refactor: shorter, new Date doesnt throw
This commit is contained in:
@@ -136,19 +136,13 @@ module.exports = function (User) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isFullnameValid(data) {
|
function isFullnameValid(data) {
|
||||||
if (!data.fullname) {
|
if (data.fullname && validator.isURL(data.fullname)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (validator.isURL(data.fullname)) {
|
|
||||||
throw new Error('[[error:invalid-fullname]]');
|
throw new Error('[[error:invalid-fullname]]');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLocationValid(data) {
|
function isLocationValid(data) {
|
||||||
if (!data.location) {
|
if (data.location && validator.isURL(data.location)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (validator.isURL(data.location)) {
|
|
||||||
throw new Error('[[error:invalid-location]]');
|
throw new Error('[[error:invalid-location]]');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,12 +152,8 @@ module.exports = function (User) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const result = new Date(data.birthday);
|
||||||
const result = new Date(data.birthday);
|
if (result && result.toString() === 'Invalid Date') {
|
||||||
if (result && result.toString() === 'Invalid Date') {
|
|
||||||
throw new Error('[[error:invalid-birthday]]');
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
throw new Error('[[error:invalid-birthday]]');
|
throw new Error('[[error:invalid-birthday]]');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user