jhipster-core
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -120,9 +120,13 @@ 'use strict'; | ||
function hasValidation(type, validation) { | ||
function hasValidation(type, validation, isAnEnum) { | ||
if (!type || !validation) { | ||
throw new buildException(exceptions.NullPointer, 'The passed type and value must not be nil.'); | ||
} | ||
return (isSQLType(type) && SQL_VALIDATIONS[type].has(validation)) | ||
|| (isMongoDBType(type) && MONGODB_VALIDATIONS[type].has(validation)) | ||
|| (isCassandraType(type) && CASSANDRA_VALIDATIONS[type].has(validation)); | ||
var concreteType = type; | ||
if (isAnEnum) { | ||
concreteType = 'Enum' | ||
} | ||
return (isSQLType(concreteType) && SQL_VALIDATIONS[concreteType].has(validation)) | ||
|| (isMongoDBType(concreteType) && MONGODB_VALIDATIONS[concreteType].has(validation)) | ||
|| (isCassandraType(concreteType) && CASSANDRA_VALIDATIONS[concreteType].has(validation)); | ||
} | ||
@@ -129,0 +133,0 @@ |
@@ -216,3 +216,3 @@ 'use strict'; | ||
let relationship = { | ||
relationshipType: relatedRelationship.type | ||
relationshipType: _.kebabCase(relatedRelationship.type) | ||
}; | ||
@@ -241,3 +241,3 @@ if (relatedRelationship.isInjectedFieldInFromRequired) { | ||
otherEntityName: _.lowerFirst(_.camelCase(relatedRelationship.from.name)), | ||
relationshipType: RelationshipTypes.MANY_TO_ONE, | ||
relationshipType: _.kebabCase(RelationshipTypes.MANY_TO_ONE), | ||
otherEntityField: _.lowerFirst(otherSplitField.otherEntityField) | ||
@@ -269,4 +269,5 @@ }; | ||
let relatedRelationship = relatedRelationships.to[i]; | ||
let relationshipType = relatedRelationship.type === RelationshipTypes.ONE_TO_MANY ? RelationshipTypes.MANY_TO_ONE : relatedRelationship.type; | ||
let relationship = { | ||
relationshipType: (relatedRelationship.type === RelationshipTypes.ONE_TO_MANY ? RelationshipTypes.MANY_TO_ONE : relatedRelationship.type) | ||
relationshipType: _.kebabCase(relationshipType) | ||
}; | ||
@@ -273,0 +274,0 @@ if (relatedRelationship.isInjectedFieldInToRequired) { |
@@ -95,3 +95,3 @@ 'use strict'; | ||
type: field.type, | ||
validations: getValidations(field) | ||
validations: getValidations(field, jdlObject.enums[field.type]) | ||
}); | ||
@@ -109,6 +109,6 @@ if (field.javadoc) { | ||
function getValidations(field) { | ||
function getValidations(field, isAnEnum) { | ||
var validations = {}; | ||
for (let i = 0; i < field.validations.length; i++) { | ||
if (!FieldTypes.hasValidation(field.type, field.validations[i].key)) { | ||
if (!FieldTypes.hasValidation(field.type, field.validations[i].key, isAnEnum)) { | ||
throw new buildException( | ||
@@ -115,0 +115,0 @@ exceptions.WrongValidation, |
@@ -71,5 +71,7 @@ 'use strict'; | ||
return Object.keys(field).every(function(key) { | ||
if (field[key].constructor === Array) | ||
if (field[key].constructor === Array) { | ||
return field[key].toString() === secondEntityField[key].toString(); | ||
else return field[key] === secondEntityField[key]; | ||
} else { | ||
return field[key] === secondEntityField[key]; | ||
} | ||
}); | ||
@@ -76,0 +78,0 @@ }); |
{ | ||
"name": "jhipster-core", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "JHipster's own domain language and core objects", | ||
@@ -5,0 +5,0 @@ "main": "module/index.js", |
@@ -45,3 +45,3 @@ 'use strict'; | ||
it('returns true', function () { | ||
expect(FieldTypes.isSQLType(new JDLEnum({name: 'Enum'}))).to.be.true; | ||
expect(FieldTypes.isSQLType(new JDLEnum({name: 'MyEnum'}))).to.be.true; | ||
}); | ||
@@ -85,3 +85,3 @@ }); | ||
it('returns true', function () { | ||
expect(FieldTypes.isMongoDBType(new JDLEnum({name: 'Enum'}))).to.be.true; | ||
expect(FieldTypes.isMongoDBType(new JDLEnum({name: 'MyEnum'}))).to.be.true; | ||
}); | ||
@@ -125,3 +125,3 @@ }); | ||
it('returns false', function () { | ||
expect(FieldTypes.isCassandraType(new JDLEnum({name: 'Enum'}))).to.be.false; | ||
expect(FieldTypes.isCassandraType(new JDLEnum({name: 'MyEnum'}))).to.be.false; | ||
}); | ||
@@ -128,0 +128,0 @@ }); |
@@ -96,3 +96,3 @@ 'use strict'; | ||
relationshipName: 'b', | ||
relationshipType: 'OneToOne', | ||
relationshipType: 'one-to-one', | ||
relationshipValidateRules: 'required' | ||
@@ -99,0 +99,0 @@ }]); |
@@ -145,4 +145,4 @@ 'use strict'; | ||
}); | ||
describe('with a required relationship', function() { | ||
it('adds it', function() { | ||
describe('with a required relationship', function () { | ||
it('adds it', function () { | ||
var input = parseFromFiles(['./test/test_files/required_relationships.jdl']); | ||
@@ -211,4 +211,22 @@ var content = JDLParser.parse(input, 'sql'); | ||
}); | ||
describe('with a required enum', function () { | ||
it('adds it', function () { | ||
var input = parseFromFiles(['./test/test_files/enum.jdl']); | ||
var content = JDLParser.parse(input, 'sql'); | ||
expect(content.enums.MyEnum).to.deep.eq(new JDLEnum({ | ||
name: 'MyEnum', | ||
values: ['AAA', 'BBB', 'CCC'] | ||
})); | ||
var enumField = new JDLField({ | ||
name: 'sourceType', | ||
type: 'MyEnum' | ||
}); | ||
enumField.addValidation(new JDLValidation({ | ||
name: Validations.REQUIRED | ||
})); | ||
expect(content.entities.MyEntity.fields.sourceType).to.deep.eq(enumField); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
382007
76
10468