Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More detailed error messages

  • Loading branch information...
commit 188d1189bcac2b9d9020459114eb1d695193f692 1 parent ea2e62d
@Baggz authored
Showing with 199 additions and 37 deletions.
  1. +199 −0 src/engines/json/errorMessages.js
  2. +0 −37 src/engines/json/messages.js
View
199 src/engines/json/errorMessages.js
@@ -0,0 +1,199 @@
+/**
+ * Messages
+ * --------------------
+ */
+var errorMessages = {
+
+ /**
+ * Maximum
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ required: function(property, propertyValue, attributeValue) {
+ return 'The ‘' + property + '’ property is required.',
+ },
+
+ /**
+ * MinLength
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ minLength: function(property, propertyValue, attributeValue) {
+ return [
+ 'The ' + property + ' property must be at least ' + attributeValue + ' characters.',
+ 'The length of the property is ' + propertyValue.length + '.'
+ ].join(' ');
+ },
+
+ /**
+ * MaxLength
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ maxLength: function(property, propertyValue, attributeValue) {
+ return [
+ 'The ' + property + ' property must not exceed ' + attributeValue + ' characters.',
+ 'The length of the property is ' + propertyValue.length + '.'
+ ].join(' ');
+ },
+
+ /**
+ * MaxLength
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ length: function(property, propertyValue, attributeValue) {
+ return [
+ 'The ' + property + ' property must be exactly ' + attributeValue + ' characters.',
+ 'The length of the property is ' + propertyValue.length + '.'
+ ].join(' ');
+ },
+
+ /**
+ * Format
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ format: function(property, propertyValue, attributeValue) {
+ return [
+ 'The ‘' + property + '’ property must be a/an ‘' + attributeValue + '’.',
+ 'The current value of the property is ‘' + propertyValue + ''
+ ].join(' ');
+ },
+
+ /**
+ * Type
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ type: function(property, propertyValue, attributeValue) {
+ return [
+ 'The ‘' + property + '’ property must be a/an ‘' + attributeValue + '’.',
+ 'The type of the property is ‘' + detectType(propertyValue) + ''
+ ].join(' ');
+ },
+
+ /**
+ * Except
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ except: function(property, propertyValue, attributeValue) {
+ return;
+ },
+
+ /**
+ * Minimum
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ minimum: function(property, propertyValue, attributeValue) {
+ return [
+ 'The minimum value of the ‘' + property + '’ must be ' + attributeValue + '.',
+ 'The current value of the property is ‘' + propertyValue + ''
+ ].join(' ');
+ },
+
+ /**
+ * Maximum
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ maximum: function(property, propertyValue, attributeValue) {
+ return [
+ 'The maximum value of the ‘' + property + '’ must be ' + attributeValue + '.',
+ 'The current value of the property is ‘' + propertyValue + '’.'
+ ].join(' ');
+ },
+
+ /**
+ * Maximum
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ pattern: function(property, propertyValue, attributeValue) {
+ return 'The ‘' + property + '’ does not match the ‘' + attributeValue + '’ pattern.';
+ },
+
+ /**
+ * MaxItems
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ maxItems: function(property, propertyValue, attributeValue) {
+ return [
+ 'The ‘' + property + '’ property must not contain more than ‘' + attributeValue + '’ items.',
+ 'Currently it contains ‘' + propertyValue.items + '’ items.'
+ ].join(' ');
+ },
+
+ /**
+ * MinItems
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ minItems: function(property, propertyValue, attributeValue) {
+ return [
+ 'The ‘' + property + '’ property must contain at least ‘' + attributeValue + '’ items.',
+ 'Currently it contains ‘' + propertyValue.items + '’ items.'
+ ].join(' ');
+ },
+
+ /**
+ * Maximum
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ divisibleBy: function(property, propertyValue, attributeValue) {
+ return 'The ‘' + property + '’ is not divisible by ‘' + attributeValue + '’.';
+ },
+
+ /**
+ * Maximum
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ uniqueItems: function(property, propertyValue, attributeValue) {
+ return 'All items in the ‘' + property + '’ property must be unique.',
+ },
+
+ /**
+ * Enum
+ *
+ * @param {string} property
+ * @param {any} propertyValue
+ * @param {string} attributeValue
+ */
+ enum: function(property, propertyValue, attributeValue) {
+ return 'Value of the ‘' + property + '’ must be ' + attributeValue.join(' or ') + '.';
+ }
+
+};
View
37 src/engines/json/messages.js
@@ -1,37 +0,0 @@
-/**
- * Messages
- * --------------------
- */
-var messages = {
-
- 'required': 'The ‘{{property}}’ property is required.',
-
- 'minLength': function(property, propertyValue, validator) {
- return 'The ' + property + ' property must be at least ' + validator + ' characters. \
- The length of the property is ' + propertyValue.length + '.';
- },
-
- 'maxLength': function(property, propertyValue, validator) {
- return 'The ' + property + ' property must not exceed ' + validator + ' characters. \
- The length of the property is ' + propertyValue.length + '.';
- },
-
- 'length': 'The ‘{{property}}’ property must be exactly {{validator}} characters.',
-
- 'format': 'The ‘{{property}}’ property must be a/an {{validator}}.',
- 'type': 'The ‘{{property}}’ property must be a/an {{validator}}.',
- 'except': 'The ‘{{property}}’ property must not be {{propertyValue}}',
- 'minimum': 'The minimum value of the ‘{{property}}’ must be {{validator}}',
- 'maximum': 'The maximum value of the ‘{{property}}’ must be {{validator}}',
- 'pattern': 'The `{{property}}` does not match the ‘{{validator}}’ pattern.',
- 'maxItems': 'The `{{property}}` property must not contain more than {{validator}} items.',
- 'minItems': 'The `{{property}}` property must contain at least {{validator}} items.',
- 'divisibleBy': 'The ‘{{property}}’ property is not divisible by {{validator}}.',
- 'uniqueItems': 'All items in the ‘{{property}}’ property must be unique.',
-
- // Advanced
- 'enum': function(property, propertyValue, validator) {
- return 'Value of the ‘' + property + '’ must be ' + validator.join(' or ') + '.';
- }
-
-};
Please sign in to comment.
Something went wrong with that request. Please try again.