Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
Fix #151 validation rule "different" makes "required" not enforced
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed May 15, 2017
1 parent 060f988 commit 25993a6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-validation-ghiscoding",
"version": "1.5.20",
"version": "1.5.21",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": [
Expand Down
13 changes: 8 additions & 5 deletions dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* Angular-Validation Directive and Service (ghiscoding)
* http://github.com/ghiscoding/angular-validation
* @author: Ghislain B.
* @version: 1.5.20
* @version: 1.5.21
* @license: MIT
* @build: Thu Apr 20 2017 12:18:09 GMT-0400 (Eastern Daylight Time)
* @build: Sun May 14 2017 23:35:23 GMT-0400 (Eastern Daylight Time)
*/
/**
* Angular-Validation Directive (ghiscoding)
Expand Down Expand Up @@ -949,7 +949,6 @@ angular
var nbValid = 0;
var validator;
var validatedObject = {};

// make an object to hold the message so that we can reuse the object by reference
// in some of the validation check (for example "matching" and "remote")
var validationElmObj = {
Expand Down Expand Up @@ -1720,7 +1719,9 @@ angular
var matchingCtrl = self.ctrl; // keep reference of matching confirmation controller
var formElmMatchingObj = getFormElementByName(self.ctrl.$name);

isValid = (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue);
isValid = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null)
? false
: (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue);

// if element to compare against has a friendlyName or if matching 2nd argument was passed, we will use that as a new friendlyName
// ex.: <input name='input1' friendly-name='Password1'/> :: we would use the friendlyName of 'Password1' not input1
Expand All @@ -1734,7 +1735,9 @@ angular

// Watch for the parent ngModel, if it change we need to re-validate the child (confirmation)
self.scope.$watch(parentNgModel, function(newVal, oldVal) {
var isWatchValid = testCondition(matchingValidator.condition, matchingCtrl.$viewValue, newVal);
var isWatchValid = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null)
? false
: (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue);

// only inspect on a parent input value change
if(newVal !== oldVal) {
Expand Down
6 changes: 3 additions & 3 deletions dist/angular-validation.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-validation-ghiscoding",
"version": "1.5.20",
"version": "1.5.21",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": "dist/angular-validation.min",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Angular Validation (Directive / Service)
`Version: 1.5.20`
`Version: 1.5.21`
### Forms Validation with Angular made easy!
##### (Concept comes from the amazing Laravel)

Expand Down
9 changes: 6 additions & 3 deletions src/validation-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ angular
var nbValid = 0;
var validator;
var validatedObject = {};

// make an object to hold the message so that we can reuse the object by reference
// in some of the validation check (for example "matching" and "remote")
var validationElmObj = {
Expand Down Expand Up @@ -1281,7 +1280,9 @@ angular
var matchingCtrl = self.ctrl; // keep reference of matching confirmation controller
var formElmMatchingObj = getFormElementByName(self.ctrl.$name);

isValid = (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue);
isValid = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null)
? false
: (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue);

// if element to compare against has a friendlyName or if matching 2nd argument was passed, we will use that as a new friendlyName
// ex.: <input name='input1' friendly-name='Password1'/> :: we would use the friendlyName of 'Password1' not input1
Expand All @@ -1295,7 +1296,9 @@ angular

// Watch for the parent ngModel, if it change we need to re-validate the child (confirmation)
self.scope.$watch(parentNgModel, function(newVal, oldVal) {
var isWatchValid = testCondition(matchingValidator.condition, matchingCtrl.$viewValue, newVal);
var isWatchValid = ((!validator.pattern || validator.pattern.toString() === "/\\S+/" || (!!rules && validator.pattern === "required")) && strValue === null)
? false
: (testCondition(validator.condition, strValue, parentNgModelVal) && !!strValue);

// only inspect on a parent input value change
if(newVal !== oldVal) {
Expand Down

0 comments on commit 25993a6

Please sign in to comment.