From 9277d12fc0052efacbeed7cf9aaeea608e5f6108 Mon Sep 17 00:00:00 2001
From: Igor Minar
Date: Tue, 13 Mar 2012 00:29:10 -0700
Subject: fix(forms): lowercase all validation error keys
---
src/directive/input.js | 156 +++++++++++++++++++++----------------------
src/directive/select.js | 2 +-
test/directive/formSpec.js | 18 ++---
test/directive/inputSpec.js | 32 ++++-----
test/directive/selectSpec.js | 6 +-
5 files changed, 107 insertions(+), 107 deletions(-)
diff --git a/src/directive/input.js b/src/directive/input.js
index 1ed1442f..fee7a082 100644
--- a/src/directive/input.js
+++ b/src/directive/input.js
@@ -15,12 +15,12 @@ var inputType = {
*
* @param {string} ng-model Assignable angular expression to data-bind to.
* @param {string=} name Property name of the form under which the control is published.
- * @param {string=} required Sets `REQUIRED` validation error key if the value is not entered.
- * @param {number=} ng-minlength Sets `MINLENGTH` validation error key if the value is shorter than
+ * @param {string=} required Sets `required` validation error key if the value is not entered.
+ * @param {number=} ng-minlength Sets `minlength` validation error key if the value is shorter than
* minlength.
- * @param {number=} ng-maxlength Sets `MAXLENGTH` validation error key if the value is longer than
+ * @param {number=} ng-maxlength Sets `maxlength` validation error key if the value is longer than
* maxlength.
- * @param {string=} ng-pattern Sets `PATTERN` validation error key if the value does not match the
+ * @param {string=} ng-pattern Sets `pattern` validation error key if the value does not match the
* RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
* patterns defined as scope expressions.
* @param {string=} ng-change Angular expression to be executed when input changes due to user
@@ -38,16 +38,16 @@ var inputType = {
@@ -77,19 +77,19 @@ var inputType = {
* @name angular.module.ng.$compileProvider.directive.input.number
*
* @description
- * Text input with number validation and transformation. Sets the `NUMBER` validation
+ * Text input with number validation and transformation. Sets the `number` validation
* error if not a valid number.
*
* @param {string} ng-model Assignable angular expression to data-bind to.
* @param {string=} name Property name of the form under which the control is published.
- * @param {string=} min Sets the `MIN` validation error key if the value entered is less then `min`.
- * @param {string=} max Sets the `MAX` validation error key if the value entered is greater then `min`.
- * @param {string=} required Sets `REQUIRED` validation error key if the value is not entered.
- * @param {number=} ng-minlength Sets `MINLENGTH` validation error key if the value is shorter than
+ * @param {string=} min Sets the `min` validation error key if the value entered is less then `min`.
+ * @param {string=} max Sets the `max` validation error key if the value entered is greater then `min`.
+ * @param {string=} required Sets `required` validation error key if the value is not entered.
+ * @param {number=} ng-minlength Sets `minlength` validation error key if the value is shorter than
* minlength.
- * @param {number=} ng-maxlength Sets `MAXLENGTH` validation error key if the value is longer than
+ * @param {number=} ng-maxlength Sets `maxlength` validation error key if the value is longer than
* maxlength.
- * @param {string=} ng-pattern Sets `PATTERN` validation error key if the value does not match the
+ * @param {string=} ng-pattern Sets `pattern` validation error key if the value does not match the
* RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
* patterns defined as scope expressions.
* @param {string=} ng-change Angular expression to be executed when input changes due to user
@@ -106,15 +106,15 @@ var inputType = {
@@ -145,17 +145,17 @@ var inputType = {
* @name angular.module.ng.$compileProvider.directive.input.url
*
* @description
- * Text input with URL validation. Sets the `URL` validation error key if the content is not a
+ * Text input with URL validation. Sets the `url` validation error key if the content is not a
* valid URL.
*
* @param {string} ng-model Assignable angular expression to data-bind to.
* @param {string=} name Property name of the form under which the control is published.
- * @param {string=} required Sets `REQUIRED` validation error key if the value is not entered.
- * @param {number=} ng-minlength Sets `MINLENGTH` validation error key if the value is shorter than
+ * @param {string=} required Sets `required` validation error key if the value is not entered.
+ * @param {number=} ng-minlength Sets `minlength` validation error key if the value is shorter than
* minlength.
- * @param {number=} ng-maxlength Sets `MAXLENGTH` validation error key if the value is longer than
+ * @param {number=} ng-maxlength Sets `maxlength` validation error key if the value is longer than
* maxlength.
- * @param {string=} ng-pattern Sets `PATTERN` validation error key if the value does not match the
+ * @param {string=} ng-pattern Sets `pattern` validation error key if the value does not match the
* RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
* patterns defined as scope expressions.
* @param {string=} ng-change Angular expression to be executed when input changes due to user
@@ -171,7 +171,7 @@ var inputType = {
@@ -210,17 +210,17 @@ var inputType = {
* @name angular.module.ng.$compileProvider.directive.input.email
*
* @description
- * Text input with email validation. Sets the `EMAIL` validation error key if not a valid email
+ * Text input with email validation. Sets the `email` validation error key if not a valid email
* address.
*
* @param {string} ng-model Assignable angular expression to data-bind to.
* @param {string=} name Property name of the form under which the control is published.
- * @param {string=} required Sets `REQUIRED` validation error key if the value is not entered.
- * @param {number=} ng-minlength Sets `MINLENGTH` validation error key if the value is shorter than
+ * @param {string=} required Sets `required` validation error key if the value is not entered.
+ * @param {number=} ng-minlength Sets `minlength` validation error key if the value is shorter than
* minlength.
- * @param {number=} ng-maxlength Sets `MAXLENGTH` validation error key if the value is longer than
+ * @param {number=} ng-maxlength Sets `maxlength` validation error key if the value is longer than
* maxlength.
- * @param {string=} ng-pattern Sets `PATTERN` validation error key if the value does not match the
+ * @param {string=} ng-pattern Sets `pattern` validation error key if the value does not match the
* RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
* patterns defined as scope expressions.
*
@@ -234,16 +234,16 @@ var inputType = {
@@ -384,10 +384,10 @@ function textInputType(scope, element, attr, ctrl) {
var validate = function(regexp, value) {
if (isEmpty(value) || regexp.test(value)) {
- ctrl.$setValidity('PATTERN', true);
+ ctrl.$setValidity('pattern', true);
return value;
} else {
- ctrl.$setValidity('PATTERN', false);
+ ctrl.$setValidity('pattern', false);
return undefined;
}
};
@@ -418,10 +418,10 @@ function textInputType(scope, element, attr, ctrl) {
var minlength = parseInt(attr.ngMinlength, 10);
var minLengthValidator = function(value) {
if (!isEmpty(value) && value.length < minlength) {
- ctrl.$setValidity('MINLENGTH', false);
+ ctrl.$setValidity('minlength', false);
return undefined;
} else {
- ctrl.$setValidity('MINLENGTH', true);
+ ctrl.$setValidity('minlength', true);
return value;
}
};
@@ -435,10 +435,10 @@ function textInputType(scope, element, attr, ctrl) {
var maxlength = parseInt(attr.ngMaxlength, 10);
var maxLengthValidator = function(value) {
if (!isEmpty(value) && value.length > maxlength) {
- ctrl.$setValidity('MAXLENGTH', false);
+ ctrl.$setValidity('maxlength', false);
return undefined;
} else {
- ctrl.$setValidity('MAXLENGTH', true);
+ ctrl.$setValidity('maxlength', true);
return value;
}
};
@@ -454,10 +454,10 @@ function numberInputType(scope, element, attr, ctrl) {
ctrl.$parsers.push(function(value) {
var empty = isEmpty(value);
if (empty || NUMBER_REGEXP.test(value)) {
- ctrl.$setValidity('NUMBER', true);
+ ctrl.$setValidity('number', true);
return value === '' ? null : (empty ? value : parseFloat(value));
} else {
- ctrl.$setValidity('NUMBER', false);
+ ctrl.$setValidity('number', false);
return undefined;
}
});
@@ -470,10 +470,10 @@ function numberInputType(scope, element, attr, ctrl) {
var min = parseFloat(attr.min);
var minValidator = function(value) {
if (!isEmpty(value) && value < min) {
- ctrl.$setValidity('MIN', false);
+ ctrl.$setValidity('min', false);
return undefined;
} else {
- ctrl.$setValidity('MIN', true);
+ ctrl.$setValidity('min', true);
return value;
}
};
@@ -486,10 +486,10 @@ function numberInputType(scope, element, attr, ctrl) {
var max = parseFloat(attr.max);
var maxValidator = function(value) {
if (!isEmpty(value) && value > max) {
- ctrl.$setValidity('MAX', false);
+ ctrl.$setValidity('max', false);
return undefined;
} else {
- ctrl.$setValidity('MAX', true);
+ ctrl.$setValidity('max', true);
return value;
}
};
@@ -501,10 +501,10 @@ function numberInputType(scope, element, attr, ctrl) {
ctrl.$formatters.push(function(value) {
if (isEmpty(value) || isNumber(value)) {
- ctrl.$setValidity('NUMBER', true);
+ ctrl.$setValidity('number', true);
return value;
} else {
- ctrl.$setValidity('NUMBER', false);
+ ctrl.$setValidity('number', false);
return undefined;
}
});
@@ -515,10 +515,10 @@ function urlInputType(scope, element, attr, ctrl) {
var urlValidator = function(value) {
if (isEmpty(value) || URL_REGEXP.test(value)) {
- ctrl.$setValidity('URL', true);
+ ctrl.$setValidity('url', true);
return value;
} else {
- ctrl.$setValidity('URL', false);
+ ctrl.$setValidity('url', false);
return undefined;
}
};
@@ -532,10 +532,10 @@ function emailInputType(scope, element, attr, ctrl) {
var emailValidator = function(value) {
if (isEmpty(value) || EMAIL_REGEXP.test(value)) {
- ctrl.$setValidity('EMAIL', true);
+ ctrl.$setValidity('email', true);
return value;
} else {
- ctrl.$setValidity('EMAIL', false);
+ ctrl.$setValidity('email', false);
return undefined;
}
};
@@ -600,12 +600,12 @@ function checkboxInputType(scope, element, attr, ctrl) {
*
* @param {string} ng-model Assignable angular expression to data-bind to.
* @param {string=} name Property name of the form under which the control is published.
- * @param {string=} required Sets `REQUIRED` validation error key if the value is not entered.
- * @param {number=} ng-minlength Sets `MINLENGTH` validation error key if the value is shorter than
+ * @param {string=} required Sets `required` validation error key if the value is not entered.
+ * @param {number=} ng-minlength Sets `minlength` validation error key if the value is shorter than
* minlength.
- * @param {number=} ng-maxlength Sets `MAXLENGTH` validation error key if the value is longer than
+ * @param {number=} ng-maxlength Sets `maxlength` validation error key if the value is longer than
* maxlength.
- * @param {string=} ng-pattern Sets `PATTERN` validation error key if the value does not match the
+ * @param {string=} ng-pattern Sets `pattern` validation error key if the value does not match the
* RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
* patterns defined as scope expressions.
* @param {string=} ng-change Angular expression to be executed when input changes due to user
@@ -624,12 +624,12 @@ function checkboxInputType(scope, element, attr, ctrl) {
*
* @param {string} ng-model Assignable angular expression to data-bind to.
* @param {string=} name Property name of the form under which the control is published.
- * @param {string=} required Sets `REQUIRED` validation error key if the value is not entered.
- * @param {number=} ng-minlength Sets `MINLENGTH` validation error key if the value is shorter than
+ * @param {string=} required Sets `required` validation error key if the value is not entered.
+ * @param {number=} ng-minlength Sets `minlength` validation error key if the value is shorter than
* minlength.
- * @param {number=} ng-maxlength Sets `MAXLENGTH` validation error key if the value is longer than
+ * @param {number=} ng-maxlength Sets `maxlength` validation error key if the value is longer than
* maxlength.
- * @param {string=} ng-pattern Sets `PATTERN` validation error key if the value does not match the
+ * @param {string=} ng-pattern Sets `pattern` validation error key if the value does not match the
* RegExp pattern expression. Expected value is `/regexp/` for inline patterns or `regexp` for
* patterns defined as scope expressions.
* @param {string=} ng-change Angular expression to be executed when input changes due to user
@@ -646,13 +646,13 @@ function checkboxInputType(scope, element, attr, ctrl) {