MCPcopy Create free account
hub / github.com/apache/cloudstack / requiredDirective

Function requiredDirective

tools/ngui/static/js/lib/angular.js:12274–12299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12272
12273
12274var requiredDirective = function() {
12275 return {
12276 require: '?ngModel',
12277 link: function(scope, elm, attr, ctrl) {
12278 if (!ctrl) return;
12279 attr.required = true; // force truthy in case we are on non input element
12280
12281 var validator = function(value) {
12282 if (attr.required && (isEmpty(value) || value === false)) {
12283 ctrl.$setValidity('required', false);
12284 return;
12285 } else {
12286 ctrl.$setValidity('required', true);
12287 return value;
12288 }
12289 };
12290
12291 ctrl.$formatters.push(validator);
12292 ctrl.$parsers.unshift(validator);
12293
12294 attr.$observe('required', function() {
12295 validator(ctrl.$viewValue);
12296 });
12297 }
12298 };
12299};
12300
12301
12302/**

Callers

nothing calls this directly

Calls 1

validatorFunction · 0.85

Tested by

no test coverage detected