UNPKG

@contentful/rich-text-types

Version:

Type definitions and constants for the Contentful rich text field type.

75 lines 2.6 kB
"use strict"; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.requiredPropertyError = exports.unknownPropertyError = exports.enumError = exports.maxSizeError = exports.minSizeError = exports.typeMismatchError = void 0; var typeMismatchError = function (_a) { var path = _a.path, property = _a.property, typeName = _a.typeName, value = _a.value; return { details: "The type of \"".concat(property, "\" is incorrect, expected type: ").concat(typeName), name: 'type', path: path.toArray(), type: typeName, value: value, }; }; exports.typeMismatchError = typeMismatchError; var minSizeError = function (_a) { var min = _a.min, value = _a.value, path = _a.path; return { name: 'size', min: min, path: path.toArray(), details: "Size must be at least ".concat(min), value: value, }; }; exports.minSizeError = minSizeError; var maxSizeError = function (_a) { var max = _a.max, value = _a.value, path = _a.path; return { name: 'size', max: max, path: path.toArray(), details: "Size must be at most ".concat(max), value: value, }; }; exports.maxSizeError = maxSizeError; var enumError = function (_a) { var expected = _a.expected, value = _a.value, path = _a.path; return { details: "Value must be one of expected values", name: 'in', expected: __spreadArray([], expected, true).sort(), path: path.toArray(), value: value, }; }; exports.enumError = enumError; var unknownPropertyError = function (_a) { var property = _a.property, path = _a.path; return { details: "The property \"".concat(property, "\" is not expected"), name: 'unexpected', path: path.toArray(), }; }; exports.unknownPropertyError = unknownPropertyError; var requiredPropertyError = function (_a) { var property = _a.property, path = _a.path; return { details: "The property \"".concat(property, "\" is required here"), name: 'required', path: path.toArray(), }; }; exports.requiredPropertyError = requiredPropertyError; //# sourceMappingURL=errors.js.map