Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-9511: fixed day min/max validation message #5965

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"dependencies": {
"@formio/bootstrap": "3.1.0-dev.1-dev.120.01bbe80",
"@formio/choices.js": "^10.2.1",
"@formio/core": "2.4.0-dev.205.f4cc49f",
"@formio/core": "v2.4.0-dev.210.e634ab4",
"@formio/text-mask-addons": "3.8.0-formio.4",
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
"abortcontroller-polyfill": "^1.7.5",
Expand Down
20 changes: 2 additions & 18 deletions src/components/day/Day.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'lodash';
import moment from 'moment';
import Field from '../_classes/field/Field';
import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils/utils';
import { getDayFormat } from '@formio/core';

export default class DayComponent extends Field {
static schema(...extend) {
Expand Down Expand Up @@ -536,24 +537,7 @@ export default class DayComponent extends Field {
* @returns {string} - the format for the value string.
*/
get format() {
let format = '';
if (this.component.dayFirst && this.showDay) {
format += 'D/';
}
if (this.showMonth) {
format += 'M/';
}
if (!this.component.dayFirst && this.showDay) {
format += 'D/';
}
if (this.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;
}
return getDayFormat(this.component);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/translations/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export default {
maxWords: '{{field}} must have no more than {{length}} words.',
min: '{{field}} cannot be less than {{min}}.',
max: '{{field}} cannot be greater than {{max}}.',
maxDate: '{{field}} should not contain date after {{- maxDate}}',
minDate: '{{field}} should not contain date before {{- minDate}}',
maxDate: '{{field}} should not contain date after {{maxDate}}',
minDate: '{{field}} should not contain date before {{minDate}}',
maxYear: '{{field}} should not contain year greater than {{maxYear}}',
minYear: '{{field}} should not contain year less than {{minYear}}',
minSelectedCount: 'You must select at least {{minCount}} items',
Expand Down
4 changes: 4 additions & 0 deletions test/unit/Day.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,13 @@ describe('Day Component', () => {
Harness.testCreate(DayComponent, comp3).then((component) => {
component.setValue('01/02/2020');
assert(!component.checkValidity(component.data, true), 'Component should not be valid');
assert.equal(component.errors?.length, 1);
assert.equal(component.errors[0]?.message, 'Date should not contain date before 1/3/2020');

component.setValue('04/01/2021');
assert(!component.checkValidity(component.data, true), 'Component should not be valid');
assert.equal(component.errors?.length, 1);
assert.equal(component.errors[0]?.message, 'Date should not contain date after 3/1/2021');

component.setValue('03/01/2021');
assert(component.checkValidity(component.data, true), 'Component should be valid');
Expand Down
39 changes: 7 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@
fuse.js "^6.6.2"
redux "^4.2.0"

"@formio/core@2.4.0-dev.205.f4cc49f":
version "2.4.0-dev.205.f4cc49f"
resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.4.0-dev.205.f4cc49f.tgz#9cf71bfe12575666ecfe40592c8ebd622784d721"
integrity sha512-uA2a5TUlr/I+pIYBTZY5SiJyg/UrmpMpzS0fgWis4+4OZHD4L81epGBVndN1M7TxpNpcqBzdpJVe/mzuilGgNA==
"@formio/core@v2.4.0-dev.210.e634ab4":
version "2.4.0-dev.210.e634ab4"
resolved "https://registry.yarnpkg.com/@formio/core/-/core-2.4.0-dev.210.e634ab4.tgz#1f8d0e216b2a103ca9945a4cdc86683be48e4bbd"
integrity sha512-t+M9K3si9Sd11dTN7Yzrek5l7V71AifjxM9RvbpJKOPr3P4f0Ceq1Z9P4vESQ8rCBAV3SAVwXzoeSGcVx7b6/Q==
dependencies:
browser-cookies "^1.2.0"
core-js "^3.39.0"
Expand Down Expand Up @@ -7442,7 +7442,7 @@ string-replace-loader@^3.1.0:
loader-utils "^2.0.0"
schema-utils "^3.0.0"

"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -7460,15 +7460,6 @@ string-width@^1.0.1, string-width@^1.0.2:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -7533,7 +7524,7 @@ stringifier@^1.3.0:
traverse "^0.6.6"
type-name "^2.0.1"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -7554,13 +7545,6 @@ strip-ansi@^4.0.0:
dependencies:
ansi-regex "^3.0.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -8657,7 +8641,7 @@ workerpool@^6.5.1:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544"
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -8683,15 +8667,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down
Loading