Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-validation

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-validation - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

test/lib/angular-mocks.1.2.16.js

4

bower.json
{
"name": "angular-validation",
"version": "1.1.0",
"version": "1.1.1",
"homepage": "https://github.com/huei90/angular-validation",

@@ -10,3 +10,3 @@ "authors": [

"main": "dist/angular-validation.js",
"keywords": ["angular", "validation", "angular validation", "validator", "client-side"],
"keywords": ["angular", "angularjs", "validation", "angular validation", "validator", "client-side"],
"license": "MIT",

@@ -13,0 +13,0 @@ "ignore": [

@@ -10,4 +10,4 @@ module.exports = function(config) {

files: [
'http://code.angularjs.org/1.2.15/angular.min.js',
'http://code.angularjs.org/1.2.15/angular-mocks.js',
'test/lib/angular.1.2.16.js',
'test/lib/angular-mocks.1.2.16.js',
'dist/angular-validation.js',

@@ -14,0 +14,0 @@ 'test/unit/*.js'

@@ -10,4 +10,4 @@ module.exports = function(config) {

files: [
'http://code.angularjs.org/1.3.0-beta.4/angular.min.js',
'http://code.angularjs.org/1.3.0-beta.4/angular-mocks.js',
'test/lib/angular.1.3.0-beta.5.js',
'test/lib/angular-mocks.1.3.0-beta.5.js',
'dist/angular-validation.js',

@@ -14,0 +14,0 @@ 'test/unit/*.js'

angular.module('myApp', ['validation'])
// -------------------
// config phase
// -------------------
.config(['$validationProvider', function ($validationProvider) {
var defaultMsg,
expression;
/**
* Setup a default message for Url
*/
defaultMsg = {
url: {
error: 'This is a error url given by user',
success: 'It\'s Url'
}
};
$validationProvider.setDefaultMsg(defaultMsg);
/**
* Setup a new Expression and default message
* In this example, we setup a IP address Expression and default Message
*/
expression = {
ip: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
};
defaultMsg = {
ip: {
error: 'This isn\'t ip address',
success: 'It\'s ip'
}
};
$validationProvider.setExpression(expression);
$validationProvider.setDefaultMsg(defaultMsg);
// or we can just setup directly
$validationProvider.setDefaultMsg({ ip: { error: 'This no ip', success: 'this ip'}});
$validationProvider.setExpression({ ip: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ });
/**
* Additions validation
*/
$validationProvider.setExpression({
/**
* @param value , user input
* @returns {boolean} true iff valid
*/
huei: function (value) {
return value === 'Huei Tan';
}
});
$validationProvider.setDefaultMsg({
huei: {
error: 'This should be Huei Tan',
success: 'Thanks!'
}
});
}])
// -------------------
// controller phase
// -------------------
.controller('index', ['$scope', '$injector', function ($scope, $injector) {
// Injector
var $validationProvider = $injector.get('$validation'),
expression,
defaultMsg;
var $validationProvider = $injector.get('$validation');

@@ -70,59 +136,2 @@

};
/**
* Setup a default message for Url
*/
defaultMsg = {
url: {
error: 'This is a error url given by user',
success: 'It\'s Url'
}
};
$validationProvider.setDefaultMsg(defaultMsg);
/**
* Setup a new Expression and default message
* In this example, we setup a IP address Expression and default Message
*/
expression = {
ip: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
};
defaultMsg = {
ip: {
error: 'This isn\'t ip address',
success: 'It\'s ip'
}
};
$validationProvider.setExpression(expression);
$validationProvider.setDefaultMsg(defaultMsg);
// or we can just setup directly
$validationProvider.setDefaultMsg({ ip: { error: 'This no ip', success: 'this ip'}});
$validationProvider.setExpression({ ip: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ });
/**
* Additions validation
*/
$validationProvider.setExpression({
/**
* @param value , user input
* @returns {boolean} true iff valid
*/
huei: function (value) {
return value === 'Huei Tan';
}
});
$validationProvider.setDefaultMsg({
huei: {
error: 'This should be Huei Tan',
success: 'Thanks!'
}
});
}]);

@@ -187,5 +187,7 @@ (function () {

var idx = 0;
for (var k in form) {
if (form[k].hasOwnProperty('$dirty')) {
$scope.$broadcast(k + 'submit');
$scope.$broadcast(k + 'submit', idx++);
}

@@ -284,2 +286,4 @@ }

if (callback) callback();
return true;
};

@@ -305,2 +309,4 @@

if (callback) callback();
return false;
};

@@ -310,2 +316,10 @@

/**
* If var is true, focus element when validate end
* @type {boolean}
***private variable
*/
var isFocusElement = false;
/**
* Check Validation with Function or RegExp

@@ -326,6 +340,6 @@ * @param scope

success: function () {
validFunc(element, attrs[successMessage], validation, scope.validCallback(), ctrl);
return validFunc(element, attrs[successMessage], validation, scope.validCallback(), ctrl);
},
error: function () {
invalidFunc(element, attrs[errorMessage], validation, scope.invalidCallback(), ctrl);
return invalidFunc(element, attrs[errorMessage], validation, scope.invalidCallback(), ctrl);
}

@@ -407,3 +421,4 @@ };

ctrl.$setViewValue(null);
isFocusElement = false;
ctrl.$setViewValue('');
ctrl.$setPristine();

@@ -423,24 +438,38 @@ ctrl.$setValidity(ctrl.$name, false);

*/
scope.$on(ctrl.$name + 'submit', function () {
var value = element[0].value;
scope.$on(ctrl.$name + 'submit', function (event, index) {
var value = element[0].value,
isValid = false;
if (index == 0) {
isFocusElement = false;
}
isValid = checkValidation(scope, element, attrs, ctrl, validation, value);
if (attrs.validMethod === 'submit') {
watch(); // clear previous scope.$watch
watch = scope.$watch('model', function (value) {
watch = scope.$watch('model', function (value, oldValue) {
// don't watch when init
if (value === oldValue) {
return;
}
// scope.$watch will translate '' to undefined
// undefined will pass the required submit /^.+/
// undefined/null will pass the required submit /^.+/
// cause some error in this validation
if (value === undefined) {
if (value === undefined || value === null) {
value = '';
}
checkValidation(scope, element, attrs, ctrl, validation, value);
isValid = checkValidation(scope, element, attrs, ctrl, validation, value);
});
return;
}
checkValidation(scope, element, attrs, ctrl, validation, value);
// Focus first input element when submit error #11
if (!isFocusElement && !isValid) {
isFocusElement = true;
element[0].focus();
}
});

@@ -454,5 +483,3 @@

var value = element[0].value;
scope.$apply(function () {
checkValidation(scope, element, attrs, ctrl, validation, value);
});
checkValidation(scope, element, attrs, ctrl, validation, value);
});

@@ -459,0 +486,0 @@

@@ -1,1 +0,1 @@

(function(){angular.module("validation",["validation.provider","validation.directive"])}).call(this),function(){angular.module("validation.provider",[]).provider("$validation",function(){var a,b,c,d,e=this,f=function(e){a=e,b=a.get("$rootScope"),c=a.get("$http"),d=a.get("$q")},g={required:/^.+$/,url:/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/,email:/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,number:/^\d+$/},h={required:{error:"This should be Required!!",success:"It's Required"},url:{error:"This should be Url",success:"It's Url"},email:{error:"This should be Email",success:"It's Email"},number:{error:"This should be Number",success:"It's Number"}};this.setExpression=function(a){angular.extend(g,a)},this.getExpression=function(a){return g[a]},this.setDefaultMsg=function(a){angular.extend(h,a)},this.getDefaultMsg=function(a){return h[a]},this.setErrorHTML=function(a){a.constructor===Function&&(e.getErrorHTML=a)},this.getErrorHTML=function(a){return'<p class="validation-invalid">'+a+"</p>"},this.setSuccessHTML=function(a){a.constructor===Function&&(e.getSuccessHTML=a)},this.getSuccessHTML=function(a){return'<p class="validation-valid">'+a+"</p>"},this.showSuccessMessage=!0,this.showErrorMessage=!0,this.checkValid=function(a){return void 0===a.$valid?!1:a&&a.$valid===!0},this.validate=function(a){for(var c in a)a[c].hasOwnProperty("$dirty")&&b.$broadcast(c+"submit");var f=d.defer();return f.promise.success=function(a){return f.promise.then(function(b){a(b)}),f.promise},f.promise.error=function(a){return f.promise.then(null,function(b){a(b)}),f.promise},e.checkValid(a)?f.resolve("success"):f.reject("error"),f.promise},this.reset=function(a){for(var c in a)a[c].hasOwnProperty("$dirty")&&b.$broadcast(c+"reset")},this.$get=["$injector",function(a){return f(a),{setErrorHTML:this.setErrorHTML,getErrorHTML:this.getErrorHTML,setSuccessHTML:this.setSuccessHTML,getSuccessHTML:this.getSuccessHTML,setExpression:this.setExpression,getExpression:this.getExpression,setDefaultMsg:this.setDefaultMsg,getDefaultMsg:this.getDefaultMsg,showSuccessMessage:this.showSuccessMessage,showErrorMessage:this.showErrorMessage,checkValid:this.checkValid,validate:this.validate,reset:this.reset}}]})}.call(this),function(){angular.module("validation.directive",["validation.provider"]).directive("validator",["$injector",function(a){var b=a.get("$validation"),c=a.get("$q"),d=a.get("$timeout"),e=function(a,c,d,e,f){a.next().html(b.showSuccessMessage?b.getSuccessHTML(c||b.getDefaultMsg(d).success):""),f.$setValidity(f.$name,!0),e&&e()},f=function(a,c,d,e,f){a.next().html(b.showErrorMessage?b.getErrorHTML(c||b.getDefaultMsg(d).error):""),f.$setValidity(f.$name,!1),e&&e()},g=function(a,d,g,h,i,j){var k=i+"SuccessMessage",l=i+"ErrorMessage",m=b.getExpression(i).constructor,n={success:function(){e(d,g[k],i,a.validCallback(),h)},error:function(){f(d,g[l],i,a.invalidCallback(),h)}};return m===Function?c.all([b.getExpression(i)(j)]).then(function(a){return a&&a.length>0&&a[0]?n.success():n.error()},function(){return n.error()}):m===RegExp&&b.getExpression(i).test(j)?n.success():n.error()};return{restrict:"A",require:"ngModel",scope:{model:"=ngModel",validCallback:"&",invalidCallback:"&"},link:function(a,b,c,e){var f=function(){},h=c.validator.split(",");b.after("<span></span>"),e.$setValidity(e.$name,!1),a.$on(e.$name+"reset",function(){f(),e.$setViewValue(null),e.$setPristine(),e.$setValidity(e.$name,!1),e.$render(),b.next().html("")}),h.forEach(function(d){return a.$on(e.$name+"submit",function(){var h=b[0].value;return"submit"===c.validMethod?(f(),void(f=a.$watch("model",function(f){void 0===f&&(f=""),g(a,b,c,e,d,f)}))):void g(a,b,c,e,d,h)}),"blur"===c.validMethod?void b.bind("blur",function(){var f=b[0].value;a.$apply(function(){g(a,b,c,e,d,f)})}):void("submit"!==c.validMethod&&"submit-only"!==c.validMethod&&a.$watch("model",function(f){if(e.$pristine&&e.$viewValue)e.$setViewValue(e.$viewValue);else if(e.$pristine)return void b.next().html("");g(a,b,c,e,d,f)}))}),d(function(){c.$observe("noValidationMessage",function(a){var c=b.next();"true"==a||1==a?c.css("display","none"):("false"==a||0==a)&&c.css("display","block")})})}}}])}.call(this);
(function(){angular.module("validation",["validation.provider","validation.directive"])}).call(this),function(){angular.module("validation.provider",[]).provider("$validation",function(){var a,b,c,d,e=this,f=function(e){a=e,b=a.get("$rootScope"),c=a.get("$http"),d=a.get("$q")},g={required:/^.+$/,url:/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/,email:/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,number:/^\d+$/},h={required:{error:"This should be Required!!",success:"It's Required"},url:{error:"This should be Url",success:"It's Url"},email:{error:"This should be Email",success:"It's Email"},number:{error:"This should be Number",success:"It's Number"}};this.setExpression=function(a){angular.extend(g,a)},this.getExpression=function(a){return g[a]},this.setDefaultMsg=function(a){angular.extend(h,a)},this.getDefaultMsg=function(a){return h[a]},this.setErrorHTML=function(a){a.constructor===Function&&(e.getErrorHTML=a)},this.getErrorHTML=function(a){return'<p class="validation-invalid">'+a+"</p>"},this.setSuccessHTML=function(a){a.constructor===Function&&(e.getSuccessHTML=a)},this.getSuccessHTML=function(a){return'<p class="validation-valid">'+a+"</p>"},this.showSuccessMessage=!0,this.showErrorMessage=!0,this.checkValid=function(a){return void 0===a.$valid?!1:a&&a.$valid===!0},this.validate=function(a){var c=0;for(var f in a)a[f].hasOwnProperty("$dirty")&&b.$broadcast(f+"submit",c++);var g=d.defer();return g.promise.success=function(a){return g.promise.then(function(b){a(b)}),g.promise},g.promise.error=function(a){return g.promise.then(null,function(b){a(b)}),g.promise},e.checkValid(a)?g.resolve("success"):g.reject("error"),g.promise},this.reset=function(a){for(var c in a)a[c].hasOwnProperty("$dirty")&&b.$broadcast(c+"reset")},this.$get=["$injector",function(a){return f(a),{setErrorHTML:this.setErrorHTML,getErrorHTML:this.getErrorHTML,setSuccessHTML:this.setSuccessHTML,getSuccessHTML:this.getSuccessHTML,setExpression:this.setExpression,getExpression:this.getExpression,setDefaultMsg:this.setDefaultMsg,getDefaultMsg:this.getDefaultMsg,showSuccessMessage:this.showSuccessMessage,showErrorMessage:this.showErrorMessage,checkValid:this.checkValid,validate:this.validate,reset:this.reset}}]})}.call(this),function(){angular.module("validation.directive",["validation.provider"]).directive("validator",["$injector",function(a){var b=a.get("$validation"),c=a.get("$q"),d=a.get("$timeout"),e=function(a,c,d,e,f){return a.next().html(b.showSuccessMessage?b.getSuccessHTML(c||b.getDefaultMsg(d).success):""),f.$setValidity(f.$name,!0),e&&e(),!0},f=function(a,c,d,e,f){return a.next().html(b.showErrorMessage?b.getErrorHTML(c||b.getDefaultMsg(d).error):""),f.$setValidity(f.$name,!1),e&&e(),!1},g=!1,h=function(a,d,g,h,i,j){var k=i+"SuccessMessage",l=i+"ErrorMessage",m=b.getExpression(i).constructor,n={success:function(){return e(d,g[k],i,a.validCallback(),h)},error:function(){return f(d,g[l],i,a.invalidCallback(),h)}};return m===Function?c.all([b.getExpression(i)(j)]).then(function(a){return a&&a.length>0&&a[0]?n.success():n.error()},function(){return n.error()}):m===RegExp&&b.getExpression(i).test(j)?n.success():n.error()};return{restrict:"A",require:"ngModel",scope:{model:"=ngModel",validCallback:"&",invalidCallback:"&"},link:function(a,b,c,e){var f=function(){},i=c.validator.split(",");b.after("<span></span>"),e.$setValidity(e.$name,!1),a.$on(e.$name+"reset",function(){f(),g=!1,e.$setViewValue(""),e.$setPristine(),e.$setValidity(e.$name,!1),e.$render(),b.next().html("")}),i.forEach(function(d){return a.$on(e.$name+"submit",function(i,j){var k=b[0].value,l=!1;0==j&&(g=!1),l=h(a,b,c,e,d,k),"submit"===c.validMethod&&(f(),f=a.$watch("model",function(f,g){f!==g&&((void 0===f||null===f)&&(f=""),l=h(a,b,c,e,d,f))})),g||l||(g=!0,b[0].focus())}),"blur"===c.validMethod?void b.bind("blur",function(){var f=b[0].value;h(a,b,c,e,d,f)}):void("submit"!==c.validMethod&&"submit-only"!==c.validMethod&&a.$watch("model",function(f){if(e.$pristine&&e.$viewValue)e.$setViewValue(e.$viewValue);else if(e.$pristine)return void b.next().html("");h(a,b,c,e,d,f)}))}),d(function(){c.$observe("noValidationMessage",function(a){var c=b.next();"true"==a||1==a?c.css("display","none"):("false"==a||0==a)&&c.css("display","block")})})}}}])}.call(this);
{
"name": "angular-validation",
"version": "1.1.0",
"version": "1.1.1",
"description": "Angular Validation",

@@ -18,3 +18,3 @@ "repository": {

"license": "MIT",
"keywords": ["angular", "validation", "angular validation", "validator", "client-side"],
"keywords": ["angular", "angularjs", "validation", "angular validation", "validator", "client-side"],
"bugs": "https://github.com/huei90/angular-validation/issues",

@@ -21,0 +21,0 @@ "devDependencies": {

@@ -1,2 +0,2 @@

angular-validation 1.1.0
angular-validation 1.1.1
=========================

@@ -126,3 +126,3 @@ [![Build Status](https://travis-ci.org/huei90/angular-validation.png?branch=master)](https://travis-ci.org/huei90/angular-validation)

**Setup a new Validation `setExpression()` `setDefaultMsg()` with `RegExp` or `Function`**
**Setup a new Validation `setExpression()` `setDefaultMsg()` with `RegExp` or `Function` in config phase**
<a name="custom-function-huei"></a>

@@ -140,52 +140,44 @@

```javascript
// Controller
// your module
angular.module('yourApp', ['validation']);
angular.module('yourApp', ['validation'])
.config(['$validationProvider', function ($validationProvider) {
// Setup `ip` validation
var expression = {
ip: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
};
// Now you can use validationProvider in your Angular Controller
function validation($scope, $injector) {
var validMsg = {
ip: {
error: 'This isn\'t ip address',
success: 'It\'s ip'
}
};
var validationProvider = $injector.get('validationProvider'); // inject validationProvider
validationProvider.setExpression(expression); // set expression
validationProvider.setDefaultMsg(validMsg); // set valid message
// Setup `ip` validation
var expression = {
ip: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
};
// Setup `huei` validation
validationProvider.setExpression({
var validMsg = {
ip: {
error: 'This isn\'t ip address',
success: 'It\'s ip'
}
};
/**
* @param value , user input
* @returns {boolean} true iff valid
*/
huei: function (value) {
return value === 'Huei Tan';
// or you can do
return $q.all([obj]).then(function () {
// ...
return true;
})
}
});
validationProvider.setExpression(expression); // set expression
validationProvider.setDefaultMsg(validMsg); // set valid message
// Setup `huei` validation
validationProvider.setExpression({
/**
* @param value , user input
* @returns {boolean} true iff valid
*/
huei: function (value) {
return value === 'Huei Tan';
// or you can do
return $q.all([obj]).then(function () {
// ...
return true;
})
}
});
validationProvider.setDefaultMsg({
huei: {
error: 'This should be Huei Tan',
success: 'Thanks!'
}
});
}
validationProvider.setDefaultMsg({
huei: {
error: 'This should be Huei Tan',
success: 'Thanks!'
}
});
}]);
```

@@ -240,3 +232,3 @@

// your angular
.config(function ($validationProvider) {
.config(['$validationProvider', function ($validationProvider) {
$validationProvider.setErrorHTML(function (msg) {

@@ -250,3 +242,3 @@ // remember to return your HTML

});
});
}]);
```

@@ -260,6 +252,6 @@

// your angular
.config(function ($validationProvider) {
.config(['$validationProvider', function ($validationProvider) {
$validationProvider.showSuccessMessage = false; // or true(default)
$validationProvider.showErrorMessage = false; // or true(default)
});
}]);
```

@@ -344,2 +336,6 @@

CHANGELOG
=====
see [release](https://github.com/huei90/angular-validation/releases)
Q & A

@@ -346,0 +342,0 @@ =====

@@ -26,2 +26,4 @@ (function () {

if (callback) callback();
return true;
};

@@ -47,2 +49,4 @@

if (callback) callback();
return false;
};

@@ -52,2 +56,10 @@

/**
* If var is true, focus element when validate end
* @type {boolean}
***private variable
*/
var isFocusElement = false;
/**
* Check Validation with Function or RegExp

@@ -68,6 +80,6 @@ * @param scope

success: function () {
validFunc(element, attrs[successMessage], validation, scope.validCallback(), ctrl);
return validFunc(element, attrs[successMessage], validation, scope.validCallback(), ctrl);
},
error: function () {
invalidFunc(element, attrs[errorMessage], validation, scope.invalidCallback(), ctrl);
return invalidFunc(element, attrs[errorMessage], validation, scope.invalidCallback(), ctrl);
}

@@ -149,3 +161,4 @@ };

ctrl.$setViewValue(null);
isFocusElement = false;
ctrl.$setViewValue('');
ctrl.$setPristine();

@@ -165,24 +178,38 @@ ctrl.$setValidity(ctrl.$name, false);

*/
scope.$on(ctrl.$name + 'submit', function () {
var value = element[0].value;
scope.$on(ctrl.$name + 'submit', function (event, index) {
var value = element[0].value,
isValid = false;
if (index == 0) {
isFocusElement = false;
}
isValid = checkValidation(scope, element, attrs, ctrl, validation, value);
if (attrs.validMethod === 'submit') {
watch(); // clear previous scope.$watch
watch = scope.$watch('model', function (value) {
watch = scope.$watch('model', function (value, oldValue) {
// don't watch when init
if (value === oldValue) {
return;
}
// scope.$watch will translate '' to undefined
// undefined will pass the required submit /^.+/
// undefined/null will pass the required submit /^.+/
// cause some error in this validation
if (value === undefined) {
if (value === undefined || value === null) {
value = '';
}
checkValidation(scope, element, attrs, ctrl, validation, value);
isValid = checkValidation(scope, element, attrs, ctrl, validation, value);
});
return;
}
checkValidation(scope, element, attrs, ctrl, validation, value);
// Focus first input element when submit error #11
if (!isFocusElement && !isValid) {
isFocusElement = true;
element[0].focus();
}
});

@@ -196,5 +223,3 @@

var value = element[0].value;
scope.$apply(function () {
checkValidation(scope, element, attrs, ctrl, validation, value);
});
checkValidation(scope, element, attrs, ctrl, validation, value);
});

@@ -201,0 +226,0 @@

@@ -184,5 +184,7 @@ (function () {

var idx = 0;
for (var k in form) {
if (form[k].hasOwnProperty('$dirty')) {
$scope.$broadcast(k + 'submit');
$scope.$broadcast(k + 'submit', idx++);
}

@@ -189,0 +191,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc