UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

31 lines (30 loc) 1.11 kB
import * as validator from 'validator'; import { BaseLocale } from '../constants/language/base/type'; import { formatString } from '../services'; export function noEmpty(_a) { var field = _a.field; var isValid = !validator.isEmpty((field.value || '').toString().trim()); var label = field.label && field.label !== ' ' ? field.label : formatString(BaseLocale.error.this); var labelText = label === formatString(BaseLocale.error.this) ? formatString(BaseLocale.error.this) : "\u300C" + label + "\u300D"; return [ isValid, "" + labelText + formatString(BaseLocale.error.no_empty_this) ]; } export function name(_a) { var field = _a.field; var value = field.value; if (value.length > 128) { return [false, formatString(BaseLocale.error.name_length128)]; } return [true, formatString(BaseLocale.error.name)]; } export function baseNoEmpty(_a) { var field = _a.field; var isValid = !validator.isEmpty((field.value || '').toString().trim()); return [isValid, formatString(BaseLocale.error.no_empty)]; }