@formio/core
Advanced tools
Comparing version
@@ -38,3 +38,3 @@ "use strict"; | ||
(0, chai_1.expect)(result).to.be.instanceOf(error_1.FieldError); | ||
(0, chai_1.expect)(result === null || result === void 0 ? void 0 : result.errorKeyOrMessage).to.equal('maxDay'); | ||
(0, chai_1.expect)(result === null || result === void 0 ? void 0 : result.errorKeyOrMessage).to.equal('maxDate'); | ||
}); | ||
@@ -62,3 +62,3 @@ }); | ||
(0, chai_1.expect)(result).to.be.instanceOf(error_1.FieldError); | ||
(0, chai_1.expect)(result === null || result === void 0 ? void 0 : result.errorKeyOrMessage).to.equal('maxDay'); | ||
(0, chai_1.expect)(result === null || result === void 0 ? void 0 : result.errorKeyOrMessage).to.equal('maxDate'); | ||
}); | ||
@@ -65,0 +65,0 @@ }); |
@@ -38,3 +38,3 @@ "use strict"; | ||
(0, chai_1.expect)(result).to.be.instanceOf(error_1.FieldError); | ||
(0, chai_1.expect)(result === null || result === void 0 ? void 0 : result.errorKeyOrMessage).to.equal('minDay'); | ||
(0, chai_1.expect)(result === null || result === void 0 ? void 0 : result.errorKeyOrMessage).to.equal('minDate'); | ||
}); | ||
@@ -62,3 +62,3 @@ }); | ||
(0, chai_1.expect)(result).to.be.instanceOf(error_1.FieldError); | ||
(0, chai_1.expect)(result === null || result === void 0 ? void 0 : result.errorKeyOrMessage).to.contain('minDay'); | ||
(0, chai_1.expect)(result === null || result === void 0 ? void 0 : result.errorKeyOrMessage).to.contain('minDate'); | ||
}); | ||
@@ -65,0 +65,0 @@ }); |
@@ -54,3 +54,3 @@ "use strict"; | ||
} | ||
const error = new error_1.FieldError('maxDay', Object.assign(Object.assign({}, context), { maxDate: String(maxDate), setting: String(maxDate) })); | ||
const error = new error_1.FieldError('maxDate', Object.assign(Object.assign({}, context), { maxDate: (0, date_1.dayjs)(maxDate).format((0, date_1.getDayFormat)(component)), setting: String(maxDate) })); | ||
return date.isBefore((0, date_1.dayjs)(maxDate)) || date.isSame((0, date_1.dayjs)(maxDate)) ? null : error; | ||
@@ -57,0 +57,0 @@ }; |
@@ -54,3 +54,3 @@ "use strict"; | ||
} | ||
const error = new error_1.FieldError('minDay', Object.assign(Object.assign({}, context), { minDate: String(minDate), setting: String(minDate) })); | ||
const error = new error_1.FieldError('minDate', Object.assign(Object.assign({}, context), { minDate: (0, date_1.dayjs)(minDate).format((0, date_1.getDayFormat)(component)), setting: String(minDate) })); | ||
return date.isAfter(minDate) || date.isSame(minDate) ? null : error; | ||
@@ -57,0 +57,0 @@ }; |
@@ -33,2 +33,3 @@ import dayjs from 'dayjs'; | ||
export declare function formatDate(value: any, format: any, timezone: any): string; | ||
export declare function getDayFormat(component: DayComponent): string; | ||
/** | ||
@@ -35,0 +36,0 @@ * Return a translated date setting. |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dayjs = exports.isPartialDay = exports.getDateValidationFormat = exports.getDateSetting = exports.formatDate = exports.momentDate = exports.convertFormatToMoment = exports.currentTimezone = void 0; | ||
exports.dayjs = exports.isPartialDay = exports.getDateValidationFormat = exports.getDateSetting = exports.getDayFormat = exports.formatDate = exports.momentDate = exports.convertFormatToMoment = exports.currentTimezone = void 0; | ||
const dayjs_1 = __importDefault(require("dayjs")); | ||
@@ -84,2 +84,26 @@ exports.dayjs = dayjs_1.default; | ||
exports.formatDate = formatDate; | ||
function getDayFormat(component) { | ||
let format = ''; | ||
const showDay = !(0, lodash_1.get)(component, 'fields.day.hide', false); | ||
const showMonth = !(0, lodash_1.get)(component, 'fields.month.hide', false); | ||
const showYear = !(0, lodash_1.get)(component, 'fields.year.hide', false); | ||
if (component.dayFirst && showDay) { | ||
format += 'D/'; | ||
} | ||
if (showMonth) { | ||
format += 'M/'; | ||
} | ||
if (!component.dayFirst && showDay) { | ||
format += 'D/'; | ||
} | ||
if (showYear) { | ||
format += 'YYYY'; | ||
return format; | ||
} | ||
else { | ||
// Trim off the "/" from the end of the format string. | ||
return format.length ? format.substring(0, format.length - 1) : format; | ||
} | ||
} | ||
exports.getDayFormat = getDayFormat; | ||
/** | ||
@@ -86,0 +110,0 @@ * Return a translated date setting. |
{ | ||
"name": "@formio/core", | ||
"version": "2.3.1", | ||
"version": "2.3.2-rc.1", | ||
"description": "The core Form.io renderering framework.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
9726746
0.07%85065
0.05%1
Infinity%25
-3.85%