@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
56 lines (55 loc) • 2.3 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.baseNoEmpty = exports.name = exports.noEmpty = void 0;
var validator = __importStar(require("validator"));
var type_1 = require("../constants/language/base/type");
var services_1 = require("../services");
function noEmpty(_a) {
var field = _a.field;
var isValid = !validator.isEmpty((field.value || '').toString().trim());
var label = field.label && field.label !== ' '
? field.label
: services_1.formatString(type_1.BaseLocale.error.this);
var labelText = label === services_1.formatString(type_1.BaseLocale.error.this)
? services_1.formatString(type_1.BaseLocale.error.this)
: "\u300C" + label + "\u300D";
return [
isValid,
"" + labelText + services_1.formatString(type_1.BaseLocale.error.no_empty_this)
];
}
exports.noEmpty = noEmpty;
function name(_a) {
var field = _a.field;
var value = field.value;
if (value.length > 128) {
return [false, services_1.formatString(type_1.BaseLocale.error.name_length128)];
}
return [true, services_1.formatString(type_1.BaseLocale.error.name)];
}
exports.name = name;
function baseNoEmpty(_a) {
var field = _a.field;
var isValid = !validator.isEmpty((field.value || '').toString().trim());
return [isValid, services_1.formatString(type_1.BaseLocale.error.no_empty)];
}
exports.baseNoEmpty = baseNoEmpty;