Skip to content

Commit

Permalink
feat(main): check enum value
Browse files Browse the repository at this point in the history
  • Loading branch information
isuke committed Feb 12, 2018
1 parent 7f88180 commit 7a57cf3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions git-consistent
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ const checkValue = (term, value, definition) => {

if (definition.required && _.isEmpty(value)) errorMessages.push(`${term} is required.`)

if (definition.type === 'enum') {
const enumNames = _.map(definition.values, 'name')
if (!enumNames.includes(value) && !_.isEmpty(value)) {
const enumNamesStr = _.map(enumNames, (enumName) => { return `'${enumName}'` }).join(', ')
errorMessages.push(`${term}'s value '${value}' is undefined. defined values ${enumNamesStr}.`)
}
}

_.forEach(rules, (ruleSetting, ruleName) => {
switch (ruleName) {
case 'firstLatter':
Expand Down

0 comments on commit 7a57cf3

Please sign in to comment.