Reputation: 6058
Hello I'm generating some Entity with the jhipster generator.
When I generate an entity relationship, I'd like to make the value in that field mandatory but unfortunately, the generator doesn't provide that option.
Is there anyway to inform the generator of this necessity? (editing the .jhipster/entity_name.json), for example?
Upvotes: 6
Views: 2335
Reputation: 428
Since this commit JHipster supports the required validation on relationships too.
This is an example from a JDL file:
relationship ManyToOne { Certificate{ca(name) required} to CertificateAuthority }
('Certificate' and 'CertificateAuthority' are entities and 'ca' is the field name)
The relevant part from the .jhipster/Certificate.json:
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipValidateRules": "required",
"relationshipName": "ca",
"otherEntityName": "certificateAuthority",
"otherEntityField": "name"
},
The generated Certificate.ca field:
@ManyToOne @NotNull private CertificateAuthority ca;
And the generated form has a 'This field is required.' warning at the Ca filed.
Upvotes: 11
Reputation: 16284
No, it would be a new feature. Feel free to create an issue in our github project and pull requests are always welcome :)
Just for others, here is the issue you opened
Upvotes: 1