Entity with default validations rules, not correctly stored
See original GitHub issueOverview of the issue
When generating an entity with default validations rules, this validation is not correctly stored in JSON.
Motivation for or Use Case
The result is a problem when exporting into JDL
Reproduce the error
Here the JSON:
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"minlength",
"maxlength"
],
"fieldValidateRulesMinlength": "5",
"fieldValidateRulesMaxlength": "25"
},
{
"fieldName": "age",
"fieldType": "Integer",
"fieldValidateRules": [
"required",
"min",
"max"
],
"fieldValidateRulesMin": 0,
"fieldValidateRulesMax": "150"
}
],
"changelogDate": "20170629215405",
"dto": "no",
"service": "no",
"entityTableName": "hello",
"pagination": "no"
}
Here the JDL:
entity Hello (hello) {
name String minlength(5) maxlength(25),
age Integer required min max(150)
}
Related issues
Following the discussion here: https://github.com/jhipster/generator-jhipster/commit/8b1fd4ca9b68b978b61225fdc31c04fbc02f7c7f#commitcomment-22841709
Suggest a Fix
The problem comes directly from the JSON file. The entity should be saved with "0"
instead of 0
, but I didn’t find where…
All our entities in Travis samples are without "0"
-> so need to be updated too
JHipster Version(s)
jhipster@0.0.0 /home/pgrimaud/tmp/21-default
└── generator-jhipster@4.5.6 -> /home/pgrimaud/projects/jhipster/generator-jhipster
JHipster configuration, a .yo-rc.json
file generated in the root folder
{
"generator-jhipster": {
"promptValues": {
"packageName": "io.github.pascalgrimaud"
},
"jhipsterVersion": "4.5.6",
"baseName": "jhipster",
"packageName": "io.github.pascalgrimaud",
"packageFolder": "io/github/pascalgrimaud",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "ehcache",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "51ee67f57224be66bdf1598160e680d469d81ec2",
"clientFramework": "angular2",
"useSass": false,
"clientPackageManager": "yarn",
"applicationType": "monolith",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": false
}
}
JDL for the Entity configuration(s) entityName.json
files generated in the .jhipster
directory
entity Hello (hello) {
name String minlength(5) maxlength(25),
age Integer required min max(150)
}
Browsers and Operating System
java version “1.8.0_131” Java™ SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot™ 64-Bit Server VM (build 25.131-b11, mixed mode)
git version 2.9.3
node: v6.11.0
npm: 5.0.3
bower: 1.8.0
gulp: [00:43:36] CLI version 1.2.2
yeoman: 1.8.5
yarn: 0.24.5
Docker version 17.05.0-ce, build 89658be
docker-compose version 1.11.2, build dfed245
Execution complete
- Checking this box is mandatory (this is just to show you read everything)
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Seems when we manually type its captured as a string. May be we could cast the values to number always
Thanks & Regards, Deepu
On Fri, Jun 30, 2017 at 8:54 AM, Pascal Grimaud notifications@github.com wrote:
I PR a fix in jhipster-core to fix the export-jdl. The other part about storing (capturing as a string and storing as a number) is really minor and isn’t necessary