Finished up with improvements to error handling.

This commit is contained in:
rainbow napkin 2025-04-29 07:05:38 -04:00
parent a6228a9fd9
commit 23ceb74883
8 changed files with 128 additions and 40 deletions

View file

@ -15,8 +15,23 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
//NPM Imports
const { check } = require('express-validator');
const { check, checkSchema } = require('express-validator');
module.exports = {
command: (field = 'command') => check(field).escape().trim().isAlphanumeric().isLength({min: 1, max: 30}),
module.exports.command = function(field = 'command'){
return checkSchema({
[field]: {
escape: true,
trim: true,
isAlphanumeric: {
errorMessage: "Toke commands must be alphanumeric."
},
isLength: {
options: {
min: 1,
max: 30
},
errorMessage: "Toke commands must be between 1 and 30 characters."
}
}
});
}