654654 scope : {
655655 src : '=' ,
656656 context : '=' ,
657+ types : '=' ,
657658 type : '@' ,
658659 title : '@'
659660 } ,
14271428 scope : {
14281429 context : '=' ,
14291430 type : '=' ,
1431+ types : '=' ,
14301432 model : '=' ,
14311433 param : '='
14321434 } ,
26392641 var errors ;
26402642
26412643 value = typeof value !== 'undefined' && value !== null && value . length === 0 ? undefined : value ;
2642- current [ validation . id ] = value ;
2644+ current [ validationId ] = value ;
26432645
26442646 errors = validator ( sanitizer ( current ) ) . errors ;
26452647
26482650 // Note: We want to allow invalid errors for testing purposes
26492651 return value ;
26502652 } else {
2651- clear ( control , validationRules [ validation . id ] ) ;
2653+ clear ( control , validationRules [ validationId ] ) ;
26522654 return value ;
26532655 }
26542656 }
26552657
26562658 var validation = $parse ( $attrs . validate ) ( $scope ) ;
2659+ var validationId = validation . id ;
26572660 var sanitationRules = { } ;
26582661 var validationRules = { } ;
26592662 var control = $ctrl ;
26602663
2661- sanitationRules [ validation . id ] = {
2664+ if ( validation && validation . type ) {
2665+ var declaredType = RAML . Inspector . Types . findType ( validation . type [ 0 ] , $scope . types ) ;
2666+ if ( declaredType ) { validation = declaredType ; }
2667+ }
2668+
2669+ sanitationRules [ validationId ] = {
26622670 type : validation . type || null ,
26632671 repeat : validation . repeat || null
26642672 } ;
26652673
2666- sanitationRules [ validation . id ] = RAML . Utils . filterEmpty ( sanitationRules [ validation . id ] ) ;
2674+ sanitationRules [ validationId ] = RAML . Utils . filterEmpty ( sanitationRules [ validationId ] ) ;
26672675
2668- validationRules [ validation . id ] = {
2676+ validationRules [ validationId ] = {
26692677 type : validation . type || null ,
26702678 minLength : validation . minLength || null ,
26712679 maxLength : validation . maxLength || null ,
26772685 repeat : validation . repeat || null
26782686 } ;
26792687
2680- validationRules [ validation . id ] = RAML . Utils . filterEmpty ( validationRules [ validation . id ] ) ;
2688+ validationRules [ validationId ] = RAML . Utils . filterEmpty ( validationRules [ validationId ] ) ;
26812689
26822690 $ctrl . $formatters . unshift ( function ( value ) {
26832691 return validate ( value ) ;
@@ -5689,7 +5697,8 @@ RAML.Inspector = (function() {
56895697 * @return {Boolean }
56905698 */
56915699 var toBoolean = function ( value ) {
5692- return [ 0 , false , '' , '0' , 'false' ] . indexOf ( value ) === - 1 ;
5700+ var index = [ 0 , false , '0' , 'false' , 1 , true , '1' , 'true' ] . indexOf ( value ) ;
5701+ return ( index !== - 1 ) ? Boolean ( index > 3 ) : null ;
56935702 } ;
56945703
56955704 /**
@@ -5729,7 +5738,7 @@ RAML.Inspector = (function() {
57295738 */
57305739 var returnValue = function ( value ) {
57315740 return value ;
5732- }
5741+ } ;
57335742
57345743 var toUnion = function ( value , key , object , configs ) {
57355744 var any = null ;
@@ -5740,7 +5749,7 @@ RAML.Inspector = (function() {
57405749 } ) ;
57415750
57425751 return any ;
5743- }
5752+ } ;
57445753
57455754 function isNativeType ( typeName ) {
57465755 typeName = typeName . replace ( '[]' , '' ) ;
@@ -6708,7 +6717,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
67086717 " </span>\n" +
67096718 " </span>\n" +
67106719 "\n" +
6711- " <raml-field context=\"context\" type=\"type\" param=\"param.definitions[0]\" model=\"context[type].values[param.definitions[0].id]\"></raml-field>\n" +
6720+ " <raml-field context=\"context\" type=\"type\" types=\"types\" param=\"param.definitions[0]\" model=\"context[type].values[param.definitions[0].id]\"></raml-field>\n" +
67126721 " </p>\n" +
67136722 " </div>\n" +
67146723 "</section>\n"
@@ -6982,7 +6991,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
69826991 " </div>\n" +
69836992 "\n" +
69846993 " <div ng-if=\"param.properties\" style=\"padding-left: 10px\">\n" +
6985- " <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" +
6994+ " <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" +
69866995 " </div>\n" +
69876996 "</div>\n"
69886997 ) ;
@@ -7212,7 +7221,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
72127221 "\n" +
72137222 " <named-parameters src=\"methodInfo.headers.plain\" context=\"context\" type=\"headers\" title=\"Headers\" enable-custom-parameters></named-parameters>\n" +
72147223 "\n" +
7215- " <named-parameters src=\"methodInfo.queryParameters\" context=\"context\" type=\"queryParameters\" title=\"Query Parameters\" enable-custom-parameters></named-parameters>\n" +
7224+ " <named-parameters src=\"methodInfo.queryParameters\" context=\"context\" type=\"queryParameters\" types=\"types\" title=\"Query Parameters\" enable-custom-parameters></named-parameters>\n" +
72167225 "\n" +
72177226 " <section ng-if=\"methodInfo.queryString\">\n" +
72187227 " <header class=\"raml-console-sidebar-row raml-console-sidebar-subheader\">\n" +
@@ -7263,7 +7272,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
72637272 " </span>\n" +
72647273 " </span>\n" +
72657274 "\n" +
7266- " <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" +
7275+ " <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" +
72677276 " </p>\n" +
72687277 " </div>\n" +
72697278 " </div>\n" +
0 commit comments