Started work on personal emotes.
This commit is contained in:
parent
db5fac83ab
commit
a4a1f6a65b
16 changed files with 248 additions and 18 deletions
|
|
@ -16,8 +16,34 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
|
||||
//NPM Imports
|
||||
const { check } = require('express-validator');
|
||||
const validator = require('validator');//We need validators for express-less code too!
|
||||
|
||||
module.exports = {
|
||||
name: (field = 'name') => check(field).escape().trim().isAlphanumeric().isLength({min: 1, max: 14}),
|
||||
link: (field = 'link') => check(field).trim().isURL()
|
||||
link: (field = 'link') => check(field).trim().isURL(),
|
||||
manualName: (input) => {
|
||||
//Trim and sanatize input
|
||||
const clean = validator.trim(validator.escape(input));
|
||||
|
||||
//if cleaned input is a proper emote name
|
||||
if(validator.isLength(clean, {min: 1, max: 14}) && validator.isAlphanumeric(clean)){
|
||||
//return cleaned input
|
||||
return clean;
|
||||
}
|
||||
|
||||
//otherwise return false
|
||||
return false;
|
||||
},
|
||||
manualLink: (input) => {
|
||||
//Trim the input
|
||||
const clean = validator.trim(input)
|
||||
|
||||
//If we have a URL return the trimmed input
|
||||
if(validator.isURL(clean)){
|
||||
return clean;
|
||||
}
|
||||
|
||||
//otherwise return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue