11import { casing } from '@stoplight/spectral-functions' ;
2- import { collectAdoption , collectAndReturnViolation , collectException } from './utils/collectionUtils.js' ;
2+ import {
3+ collectAdoption ,
4+ collectAndReturnViolation ,
5+ collectException ,
6+ handleInternalError ,
7+ } from './utils/collectionUtils.js' ;
38import { hasException } from './utils/exceptions.js' ;
49import { resolveObject } from './utils/componentUtils.js' ;
510
@@ -15,14 +20,31 @@ export default (input, options, { path, documentInventory }) => {
1520 return ;
1621 }
1722
23+ if ( input === 'mongoDBEmployeeAccessGrant' ) {
24+ console . log ( property ) ;
25+ console . log ( path ) ;
26+ }
27+
1828 if ( hasException ( property , RULE_NAME ) ) {
1929 collectException ( property , RULE_NAME , path ) ;
2030 return ;
2131 }
2232
23- if ( casing ( input , { type : 'camel' , disallowDigits : true } ) ) {
24- const errorMessage = `Property " ${ input } " must use camelCase format.` ;
25- return collectAndReturnViolation ( path , RULE_NAME , errorMessage ) ;
33+ const errors = checkViolationsAndReturnErrors ( input , path ) ;
34+ if ( errors . length !== 0 ) {
35+ return collectAndReturnViolation ( path , RULE_NAME , errors ) ;
2636 }
2737 collectAdoption ( path , RULE_NAME ) ;
2838} ;
39+
40+ function checkViolationsAndReturnErrors ( input , path ) {
41+ try {
42+ if ( casing ( input , { type : 'camel' , disallowDigits : true } ) ) {
43+ const errorMessage = `Property "${ input } " must use camelCase format.` ;
44+ return [ { path, message : errorMessage } ] ;
45+ }
46+ return [ ] ;
47+ } catch ( e ) {
48+ handleInternalError ( RULE_NAME , path , e ) ;
49+ }
50+ }
0 commit comments