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

Field length error message #95

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/cloud-element-templates/util/propertyUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,11 +871,11 @@ export function validateProperty(value, property, translate = defaultTranslate)
}

if (maxLength && (value || '').length > maxLength) {
return `${label} ${translate('must have max length {maxLength}.', { maxLength })}`;
return `${label} ${translate('Field cannot exceed {maxLength} characters.', { maxLength })}`;
}

if (minLength && (value || '').length < minLength) {
return `${label} ${translate('must have min length {minLength}.', { minLength })}`;
return `${label} ${translate('Field must be at least {minLength} characters.', { minLength })}`;
}

let { pattern } = constraints;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,11 @@ function propertyValidator(translate, property) {
}

if (maxLength && value.length > maxLength) {
return translate('Must have max length {maxLength}.', { maxLength });
return translate('Field cannot exceed {maxLength} characters.', { maxLength });
}

if (minLength && value.length < minLength) {
return translate('Must have min length {minLength}.', { minLength });
return translate('Field must be at least {minLength} characters.', { minLength });
}

let { pattern } = constraints;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const invalid = [
},
report: {
id: 'Task_1',
message: 'Test Property must have min length 5.',
message: 'Test Property Field must be at least 5 characters.',
propertiesPanel: { entryIds: [ 'custom-entry-constraints.minLength-0' ] },
name: 'a'
}
Expand All @@ -75,7 +75,7 @@ const invalid = [
},
report: {
id: 'Task_1',
message: 'Test Property must have max length 5.',
message: 'Test Property Field cannot exceed 5 characters.',
propertiesPanel: { entryIds: [ 'custom-entry-constraints.maxLength-0' ] },
name: 'Very Long Name'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
},
{
"label": "String - MaxLength",
"description": "Must have max length 5",
"description": "Field cannot exceed 5 characters.",
"type": "String",
"group": "input",
"binding": {
Expand Down Expand Up @@ -314,7 +314,7 @@
},
{
"label": "TextArea - MaxLength",
"description": "Must have max length 5",
"description": "Field cannot exceed 5 characters.",
"type": "Text",
"group": "textarea",
"binding": {
Expand Down Expand Up @@ -404,7 +404,7 @@
},
{
"label": "Select - MaxLength",
"description": "Must have max length 5",
"description": "Field cannot exceed 5 characters.",
"type": "Dropdown",
"group": "select",
"binding": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ describe('provider/cloud-element-templates - CustomProperties', function() {
input = domQuery(selector, entry);

// assume
expectError(entry, `${name} - MinLength must have min length 5.`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This File was accidentally commited in #64 and was removed with 6d2e524 already. Please rebase your work to the latest main branch to resolve the conflict

expectError(entry, `${name} - Field must be at least 5 characters.`);

// when
changeInput(input, 'FOOOOOOO');
Expand All @@ -1589,7 +1589,7 @@ describe('provider/cloud-element-templates - CustomProperties', function() {
changeInput(input, 'FOOOOOOO');

// then
expectError(entry, `${name} - MaxLength must have max length 5.`);
expectError(entry, `${name} - MaxLength Field cannot exceed 5 characters.`);
});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ describe('provider/cloud-element-templates - CustomProperties', function() {
input = domQuery(selector, entry);

// assume
expectError(entry, `${name} - MinLength must have min length 5.`);
expectError(entry, `${name} - MinLength Field must be at least 5 characters.`);

// when
changeInput(input, 'FOOOOOOO');
Expand All @@ -1590,7 +1590,7 @@ describe('provider/cloud-element-templates - CustomProperties', function() {
changeInput(input, 'FOOOOOOO');

// then
expectError(entry, `${name} - MaxLength must have max length 5.`);
expectError(entry, `${name} - MaxLength Field cannot exceed 5 characters.`);
});


Expand Down
2 changes: 1 addition & 1 deletion test/spec/element-templates/fixtures/complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
},
{
"label": "MaxLength",
"description": "Must have max length 5",
"description": "Field cannot exceed 5 characters.",
"type": "String",
"binding": {
"type": "camunda:property",
Expand Down
6 changes: 3 additions & 3 deletions test/spec/element-templates/properties/CustomProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
},
{
"label": "String - MaxLength",
"description": "Must have max length 5",
"description": "Field cannot exceed 5 characters.",
"type": "String",
"group": "input",
"binding": {
Expand Down Expand Up @@ -440,7 +440,7 @@
},
{
"label": "TextArea - MaxLength",
"description": "Must have max length 5",
"description": "Field cannot exceed 5 characters.",
"type": "Text",
"group": "textarea",
"binding": {
Expand Down Expand Up @@ -530,7 +530,7 @@
},
{
"label": "Select - MaxLength",
"description": "Must have max length 5",
"description": "Field cannot exceed 5 characters.",
"type": "Dropdown",
"group": "select",
"binding": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ describe('provider/element-templates - CustomProperties', function() {
input = domQuery(selector, entry);

// assume
expectError(entry, 'Must have min length 5.');
expectError(entry, 'Field must be at least 5 characters.');

// when
changeInput(input, 'FOOOOOOO');
Expand All @@ -1574,7 +1574,7 @@ describe('provider/element-templates - CustomProperties', function() {
changeInput(input, 'FOOOOOOO');

// then
expectError(entry, 'Must have max length 5.');
expectError(entry, 'Field cannot exceed 5 characters.');
});


Expand Down