Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/@buffetjs/utils/dist/ drwxr-xr-x | |
| Viewing file: Select action/file-type: "use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _lodash = require("lodash");
var yup = _interopRequireWildcard(require("yup"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var createYupSchema = function createYupSchema(type, validations) {
var translatedErrors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var schema = yup.mixed();
if (['text', 'textarea', 'email', 'password', 'select'].includes(type)) {
schema = yup.string(translatedErrors.string);
}
if (type === 'email') {
schema = schema.email(translatedErrors.email);
}
if (type === 'number') {
schema = yup.number().transform(function (cv) {
return (0, _lodash.isNaN)(cv) ? undefined : cv;
}).typeError(translatedErrors.number);
}
if (['date', 'datetime'].includes(type)) {
schema = schema.date().typeError(translatedErrors.date);
}
Object.keys(validations).forEach(function (validation) {
var validationValue = validations[validation];
if (!!validationValue || !(0, _lodash.isBoolean)(validationValue) && Number.isInteger(Math.floor(validationValue)) || validationValue === 0) {
switch (validation) {
case 'required':
schema = schema.required(translatedErrors.required);
break;
case 'max':
schema = schema.max(validationValue, translatedErrors.max);
break;
case 'maxLength':
schema = schema.max(validationValue, translatedErrors.maxLength);
break;
case 'min':
schema = schema.min(validationValue, translatedErrors.min);
break;
case 'minLength':
schema = schema.min(validationValue, translatedErrors.minLength);
break;
case 'regex':
schema = schema.matches(validationValue, translatedErrors.regex);
break;
case 'lowercase':
if (['text', 'textarea', 'email', 'string'].includes(type)) {
schema = schema.strict().lowercase();
}
break;
case 'uppercase':
if (['text', 'textarea', 'email', 'string'].includes(type)) {
schema = schema.strict().uppercase(translatedErrors.uppercase);
}
break;
case 'positive':
if (['number', 'integer', 'bigint', 'float', 'decimal'].includes(type)) {
schema = schema.positive();
}
break;
case 'negative':
if (['number', 'integer', 'bigint', 'float', 'decimal'].includes(type)) {
schema = schema.negative();
}
break;
default:
}
}
});
return schema;
};
var _default = createYupSchema;
exports["default"] = _default; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0061 ]-- |