404

[ Avaa Bypassed ]




Upload:

Command:

botdev@18.191.44.70: ~ $
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.contains = exports.combine = exports.validators = exports.validate = void 0;
const chalk = require("chalk");
const errors_1 = require("../errors");
const string_1 = require("../utils/string");
function validate(input, key, validatorsToUse) {
    const errors = [];
    for (const validator of validatorsToUse) {
        const message = validator(input, key);
        if (message !== true) {
            errors.push({ key, message, validator });
        }
    }
    if (errors.length > 0) {
        throw new errors_1.InputValidationError('Invalid inputs.', errors);
    }
}
exports.validate = validate;
exports.validators = {
    required(input, key) {
        if (!input) {
            if (key) {
                return `${chalk.green(key)} must not be empty.`;
            }
            else {
                return 'Must not be empty.';
            }
        }
        return true;
    },
    email(input, key) {
        if (!string_1.isValidEmail(input)) {
            if (key) {
                return `${chalk.green(key)} is an invalid email address.`;
            }
            else {
                return 'Invalid email address.';
            }
        }
        return true;
    },
    url(input, key) {
        if (!string_1.isValidURL(input)) {
            if (key) {
                return `${chalk.green(key)} is an invalid URL.`;
            }
            else {
                return 'Invalid URL.';
            }
        }
        return true;
    },
    numeric(input, key) {
        if (isNaN(Number(input))) {
            if (key) {
                return `${chalk.green(key)} must be numeric.`;
            }
            else {
                return 'Must be numeric.';
            }
        }
        return true;
    },
    slug(input, key) {
        if (!input || string_1.slugify(input) !== input) {
            if (key) {
                return `${chalk.green(key)} is an invalid slug (machine name).`;
            }
            else {
                return 'Invalid slug (machine name).';
            }
        }
        return true;
    },
};
function combine(...validators) {
    return (input, key) => {
        for (const validator of validators) {
            const message = validator(input, key);
            if (message !== true) {
                return message;
            }
        }
        return true;
    };
}
exports.combine = combine;
function contains(values, { caseSensitive = true }) {
    if (!caseSensitive) {
        values = values.map(v => typeof v === 'string' ? v.toLowerCase() : v);
    }
    return (input, key) => {
        if (!caseSensitive && typeof input === 'string') {
            input = input.toLowerCase();
        }
        if (values.indexOf(input) === -1) {
            const strValues = values.filter(v => typeof v === 'string'); // TODO: typescript bug?
            const mustBe = (strValues.length !== values.length ? 'unset or one of' : 'one of') + ': ' + strValues.map(v => chalk.green(v)).join(', ');
            const fmtPretty = (v) => typeof v === 'undefined' ? 'unset' : (v === '' ? 'empty' : chalk.green(v));
            if (key) {
                return `${chalk.green(key)} must be ${mustBe} (not ${fmtPretty(input)})`;
            }
            else {
                return `Must be ${mustBe} (not ${fmtPretty(input)})`;
            }
        }
        return true;
    };
}
exports.contains = contains;

Filemanager

Name Type Size Permission Actions
colors.d.ts File 658 B 0644
colors.js File 1.52 KB 0644
command.d.ts File 4.19 KB 0644
command.js File 9.7 KB 0644
completion.d.ts File 1.26 KB 0644
completion.js File 1.84 KB 0644
config.d.ts File 994 B 0644
config.js File 2.14 KB 0644
executor.d.ts File 4.73 KB 0644
executor.js File 5.93 KB 0644
help.d.ts File 11.16 KB 0644
help.js File 25.15 KB 0644
index.d.ts File 218 B 0644
index.js File 537 B 0644
options.d.ts File 4.6 KB 0644
options.js File 10.38 KB 0644
validators.d.ts File 401 B 0644
validators.js File 3.4 KB 0644