UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

56 lines (47 loc) 1.73 kB
import _regeneratorRuntime from "@babel/runtime/regenerator"; import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import isString from 'lodash/isString'; import ValidationResult from '../ValidationResult'; import { $l } from '../../locale-context'; export default function customError(_x, _x2) { return _customError.apply(this, arguments); } function _customError() { _customError = _asyncToGenerator( /*#__PURE__*/ _regeneratorRuntime.mark(function _callee(value, props) { var customValidator, name, record, form, result; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: customValidator = props.customValidator, name = props.name, record = props.record, form = props.form; if (!(typeof customValidator === 'function')) { _context.next = 7; break; } _context.next = 4; return customValidator(value, name, record || form); case 4: result = _context.sent; if (!(isString(result) || result === false)) { _context.next = 7; break; } return _context.abrupt("return", new ValidationResult({ validationMessage: result || $l('Validator', 'unknown'), value: value, ruleName: 'customError' })); case 7: return _context.abrupt("return", true); case 8: case "end": return _context.stop(); } } }, _callee); })); return _customError.apply(this, arguments); } //# sourceMappingURL=customError.js.map