694694 scope : {
695695 src : '=' ,
696696 context : '=' ,
697+ types : '=' ,
697698 type : '@' ,
698699 title : '@'
699700 } ,
14801481 scope : {
14811482 context : '=' ,
14821483 type : '=' ,
1484+ types : '=' ,
14831485 model : '=' ,
14841486 param : '='
14851487 } ,
26922694 var errors ;
26932695
26942696 value = typeof value !== 'undefined' && value !== null && value . length === 0 ? undefined : value ;
2695- current [ validation . id ] = value ;
2697+ current [ validationId ] = value ;
26962698
26972699 errors = validator ( sanitizer ( current ) ) . errors ;
26982700
27012703 // Note: We want to allow invalid errors for testing purposes
27022704 return value ;
27032705 } else {
2704- clear ( control , validationRules [ validation . id ] ) ;
2706+ clear ( control , validationRules [ validationId ] ) ;
27052707 return value ;
27062708 }
27072709 }
27082710
27092711 var validation = $parse ( $attrs . validate ) ( $scope ) ;
2712+ var validationId = validation . id ;
27102713 var sanitationRules = { } ;
27112714 var validationRules = { } ;
27122715 var control = $ctrl ;
27132716
2714- sanitationRules [ validation . id ] = {
2717+ if ( validation && validation . type ) {
2718+ var declaredType = RAML . Inspector . Types . findType ( validation . type [ 0 ] , $scope . types ) ;
2719+ if ( declaredType ) { validation = declaredType ; }
2720+ }
2721+
2722+ sanitationRules [ validationId ] = {
27152723 type : validation . type || null ,
27162724 repeat : validation . repeat || null
27172725 } ;
27182726
2719- sanitationRules [ validation . id ] = RAML . Utils . filterEmpty ( sanitationRules [ validation . id ] ) ;
2727+ sanitationRules [ validationId ] = RAML . Utils . filterEmpty ( sanitationRules [ validationId ] ) ;
27202728
2721- validationRules [ validation . id ] = {
2729+ validationRules [ validationId ] = {
27222730 type : validation . type || null ,
27232731 minLength : validation . minLength || null ,
27242732 maxLength : validation . maxLength || null ,
27302738 repeat : validation . repeat || null
27312739 } ;
27322740
2733- validationRules [ validation . id ] = RAML . Utils . filterEmpty ( validationRules [ validation . id ] ) ;
2741+ validationRules [ validationId ] = RAML . Utils . filterEmpty ( validationRules [ validationId ] ) ;
27342742
27352743 $ctrl . $formatters . unshift ( function ( value ) {
27362744 return validate ( value ) ;
@@ -5744,7 +5752,9 @@ RAML.Inspector = (function() {
57445752 * @return {Boolean }
57455753 */
57465754 var toBoolean = function ( value ) {
5747- return [ 0 , false , '' , '0' , 'false' ] . indexOf ( value ) === - 1 ;
5755+ if ( [ 0 , false , '0' , 'false' ] . indexOf ( value ) !== - 1 ) return false ;
5756+ if ( [ 1 , true , '1' , 'true' ] . indexOf ( value ) !== - 1 ) return true ;
5757+ return null ;
57485758 } ;
57495759
57505760 /**
@@ -5784,7 +5794,7 @@ RAML.Inspector = (function() {
57845794 */
57855795 var returnValue = function ( value ) {
57865796 return value ;
5787- }
5797+ } ;
57885798
57895799 var toUnion = function ( value , key , object , configs ) {
57905800 var any = null ;
@@ -5795,7 +5805,7 @@ RAML.Inspector = (function() {
57955805 } ) ;
57965806
57975807 return any ;
5798- }
5808+ } ;
57995809
58005810 function isNativeType ( typeName ) {
58015811 typeName = typeName . replace ( '[]' , '' ) ;
@@ -6764,7 +6774,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
67646774 " </span>\n" +
67656775 " </span>\n" +
67666776 "\n" +
6767- " <raml-field context=\"context\" type=\"type\" param=\"param.definitions[0]\" model=\"context[type].values[param.definitions[0].id]\"></raml-field>\n" +
6777+ " <raml-field context=\"context\" type=\"type\" types=\"types\" param=\"param.definitions[0]\" model=\"context[type].values[param.definitions[0].id]\"></raml-field>\n" +
67686778 " </p>\n" +
67696779 " </div>\n" +
67706780 "</section>\n"
@@ -7040,7 +7050,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
70407050 " </div>\n" +
70417051 "\n" +
70427052 " <div ng-if=\"param.properties\" style=\"padding-left: 10px\">\n" +
7043- " <raml-field ng-repeat=\"aParam in param.properties\" context=\"context\" type=\"type\" param=\"aParam[0]\" ng-init=\"model[0][aParam[0].name] = [undefined]\" model=\"model[0][aParam[0].name]\"></raml-field>\n" +
7053+ " <raml-field ng-repeat=\"aParam in param.properties\" context=\"context\" type=\"type\" types=\"types\" param=\"aParam[0]\" ng-init=\"model[0][aParam[0].name] = [undefined]\" model=\"model[0][aParam[0].name]\"></raml-field>\n" +
70447054 " </div>\n" +
70457055 "</div>\n"
70467056 ) ;
@@ -7270,7 +7280,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
72707280 "\n" +
72717281 " <named-parameters src=\"methodInfo.headers.plain\" context=\"context\" type=\"headers\" title=\"Headers\" enable-custom-parameters></named-parameters>\n" +
72727282 "\n" +
7273- " <named-parameters src=\"methodInfo.queryParameters\" context=\"context\" type=\"queryParameters\" title=\"Query Parameters\" enable-custom-parameters></named-parameters>\n" +
7283+ " <named-parameters src=\"methodInfo.queryParameters\" context=\"context\" type=\"queryParameters\" types=\"types\" title=\"Query Parameters\" enable-custom-parameters></named-parameters>\n" +
72747284 "\n" +
72757285 " <section ng-if=\"methodInfo.queryString\">\n" +
72767286 " <header class=\"raml-console-sidebar-row raml-console-sidebar-subheader\">\n" +
@@ -7321,7 +7331,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
73217331 " </span>\n" +
73227332 " </span>\n" +
73237333 "\n" +
7324- " <raml-field context=\"context\" type=\"type\" param=\"param.definitions[0]\" model=\"context.bodyContent.definitions[context.bodyContent.selected].values[param.definitions[0].id]\"></raml-field>\n" +
7334+ " <raml-field context=\"context\" type=\"type\" types=\"types\" param=\"param.definitions[0]\" model=\"context.bodyContent.definitions[context.bodyContent.selected].values[param.definitions[0].id]\"></raml-field>\n" +
73257335 " </p>\n" +
73267336 " </div>\n" +
73277337 " </div>\n" +
0 commit comments