From 3afb86ef3703af3a1280cebeb11da0b2d94335f0 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 23 Jan 2015 22:27:05 -0800 Subject: [PATCH] CRM-15856 - crmUi - Add generic, field-independent validator (crmUiValidate). --- js/angular-crm-ui.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/angular-crm-ui.js b/js/angular-crm-ui.js index 1d18f714c2..44b19bdb28 100644 --- a/js/angular-crm-ui.js +++ b/js/angular-crm-ui.js @@ -458,6 +458,22 @@ }; }) + // example: + // example: + // Generic, field-independent validator. + .directive('crmUiValidate', function() { + return { + restrict: 'EA', + require: 'ngModel', + link: function(scope, element, attrs, ngModel) { + var validationKey = attrs.crmUiValidateName ? attrs.crmUiValidateName : 'crmUiValidate'; + scope.$watch(attrs.crmUiValidate, function(newValue){ + ngModel.$setValidity(validationKey, !!newValue); + }); + } + }; + }) + // like ng-show, but hides/displays elements using "visibility" which maintains positioning // example
...content...
.directive('crmUiVisible', function($parse) { -- 2.25.1