Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Amanda v0.4.0 #35

Merged
merged 304 commits into from

1 participant

@Baggz
Owner

Hi everyone!

I would like to introduce you the latest version of Amanda (v0.4.0).

First change (and probably the most important) is a change in the direction. Amanda is no longer just a validation library for JSON Schema. It's aiming to be an universal validation library, currently it supports only the JSON Schema Internet Draft, but I'm planning to add Orderly, Relax NG and others very soon.

Example

/**
 * Schema
 */
var schema = {
  type: 'object',
  properties: {
    name: {
      required: true,
      type: 'string',
      length: 7
    }
  }
};

/**
 * Data
 */
var data = {
  name: 'Kenneth'
};

// Initialize a JSON Schema validator
var jsonSchemaValidator = amanda('json');

// Validate the data against the schema
jsonSchemaValidator.validate(data, schema, function(error) {
  // Do something...
});

Compliant with the JSON Schema Internet Draft

Amanda is now more compliant with the JSON Schema Internet Draft. I have added new attributes.

Also the format attribute supports all formats defined by the JSON Schema Internet Draft plus some custom formats like alpha, alphanumeric, decimal, percentage and others.

Another notable change is that validators has been renamed to attributes. Instead of calling the addValidator method, please use the addAttribute method. This changes also applies to the Error object.

  • addValidatoraddAttribute
  • validatorattribute
  • validatorNameattributeName
  • validatorValueattributeValue
  • ...

Attributes API

The thing I'm the most excited about is enhanced attributes API. You already know you can add a custom attribute.

var myValidator = amanda('json');

/**
 * MyAttribute
 */
var myAttribute = function(property, propertyValue, attributeValue, propertyAttributes, callback) {
  // Do something...
};

myValidator.addAttribute('test', myAttribute);

An error can be reported by calling the addError method.

var myAttribute = function(property, propertyValue, attributeValue, propertyAttributes, callback) {

  if ( ... ) {
    this.addError('Lorem ipsum dolor error!');
  }

  return callback();

}

Attributes are more powerful with the new enhanced attributes API. They have an access to the internal API (via this keyword).

The same applies for internal properties.

  • An instance (this.instance)
  • A schema (this.schema)
  • An Error object (this.errors)
  • All the attributes (this.attributes)

Again, all these methods and properties are available under the this keyword.

Documentation

The documentation has been completely revamped. It could be found in the /docs/ folder. To be noted, the documentation is not complete yet.

Tests

All tests have been rewritten into Mocha in order to test the library in the browser.

Error Messages

More accurate error messages, that's it.

Build

Amanda was separated into multiple files. I hope you and the ‘make’ command get along well.

Conclusion

Although I was trying hard to not break the current API, in some cases it could happen. Please keep this in mind.

added some commits
@Baggz Rewrite the ‘maximum’ test into Mocha 05bd651
@Baggz Rewrite the ‘maxItems’ test into Mocha 6bdaec8
@Baggz Rewrite the ‘maxLength’ test into Mocha 96b834e
@Baggz Rewrite the ‘minimum’ test into Mocha 5fcee78
@Baggz Rewrite the ‘minItems’ test into Mocha 339d90c
@Baggz Rewrite the ‘minLength’ test into Mocha 2998b66
@Baggz Rewrite the ‘pattern’ test into Mocha 3d6507f
@Baggz Rewrite the ‘array’ test into Mocha f686111
@Baggz Rewrite the ‘boolean’ test into Mocha b831ef1
@Baggz Rewrite the ‘function’ test into Mocha d1ef558
@Baggz Rewrite the ‘number’ test into Mocha f58b92f
@Baggz Rewrite the ‘object’ test into Mocha e10f95d
@Baggz Rewrite the ‘string’ test into Mocha d1b805e
@Baggz Rewrite the ‘alpha’ test into Mocha 206fe94
@Baggz Rewrite the ‘alphanumeric’ test into Mocha 388d248
@Baggz Rewrite the ‘decimal’ test into Mocha 0b565d3
@Baggz Rewrite the ‘email’ test into Mocha 0943172
@Baggz Rewrite the ‘date’ test into Mocha bd76af6
@Baggz Rewrite the ‘int’ test into Mocha 17c2a8a
@Baggz Rewrite the ‘ip’ test into Mocha 4ab593d
@Baggz Rewrite the ‘port’ test into Mocha d158699
@Baggz Remove the obsolete ‘maximum’ test d8a7691
@Baggz Remove the obsolete ‘maxItems’ test suite f1ced5f
@Baggz Remove the obsolete ‘minItems’ test suite 2dc56ea
@Baggz Remove the obsolete ‘minimum’ test suite 99373b4
@Baggz Remove the obsolete ‘maxLength’ test suite ce6d936
@Baggz Remove the obsolete ‘minLength’ test suite 4f4fade
@Baggz Remove the obsolete ‘exclusiveMaximum’ test suite 76810a5
@Baggz Remove the obsolete ‘exclusiveMinimum’ test suite 2b5750f
@Baggz Remove the obsolete ‘alpha’ test suite 0cd0f05
@Baggz Remove the obsolete ‘alphanumeric’ test suite c33270d
@Baggz Remove the obsolete ‘date’ test suite 45f85a6
@Baggz Remove the obsolete ‘decimal’ test suite 4d91902
@Baggz Remove the obsolete ‘email’ test suite b4d19d5
@Baggz Remove the obsolete ‘int’ test suite 9ae27ae
@Baggz Remove the obsolete ‘ip’ test suite 39d4ab6
@Baggz Remove the obsolete ‘enum’ test suite 77030b0
@Baggz Remove the obsolete ‘except’ test suite 63c9e10
@Baggz Remove the obsolete ‘divisibleBy’ test suite c2d64de
@Baggz Remove the obsolete ‘length’ test suite dd1c082
@Baggz Remove the obsolete ‘pattern’ test suite f277eb3
@Baggz Remove the obsolete ‘array’ test suite a112ade
@Baggz Remove the obsolete ‘boolean’ test suite 27e3152
@Baggz Remove the obsolete ‘function’ test suite b39aed0
@Baggz Remove the obsolete ‘number’ test suite b3e2d8a
@Baggz Remove the obsolete ‘object’ test suite 443d1f3
@Baggz Remove the obsolete ‘string’ test suite bd41e0c
@Baggz Remove the obsolete ‘uniqueItems’ test suite 273dcf4
@Baggz Remove the obsolete ‘port’ test suite c7abada
@Baggz Removed the ‘amanda.min.js’ file 560146a
@Baggz Remove the obsolete ‘percentage’ test suite 3fb8e5e
@Baggz Remove the obsolete ‘regex’ test suite bedc642
@Baggz Remove the obsolete ‘unsignedInt’ test suite b3d327a
@Baggz Remove the obsolete ‘url’ test suite 11b4dcc
@Baggz Rewrite the ‘percentage’ test suite into Mocha c731609
@Baggz Rewrite the ‘regex’ test suite into Mocha 57ae3b9
@Baggz Rewrite the ‘unsignedInt’ test suite into Mocha 04d5978
@Baggz Rewrite the ‘url’ test suite into Mocha fb46f77
@Baggz Added a new test resource ‘domainNames’ 28e45f8
@Baggz Added a new test resource ‘domains’ bb2d254
@Baggz Added a new test resource ‘emails’ 61efc12
@Baggz Added a new test resource ‘params’ b40854f
@Baggz Remove the obsolete ‘Arrays’ test suite 3fad3cb
@Baggz Remove the obsolete ‘ArraysSingleError’ test suite 05c4582
@Baggz Remove the obsolete ‘mixed’ test suite 02b8321
@Baggz Remove the obsolete ‘MixedSingleError’ test suite f67fabe
@Baggz Remove the obsolete ‘MultipleValidators’ test suite 8a5b5fb
@Baggz Remove the obsolete ‘Objects’ test suite 19a67d4
@Baggz Remove the obsolete ‘ObjectsSingleError’ test suite 4692b20
@Baggz Remove the obsolete ‘Objects’ test suite f881ec4
@Baggz Remove the obsolete ‘ObjectsSingleError’ test suite 59f5ebb
@Baggz Remove the obsolete ‘Required’ test suite 1932d25
@Baggz Remove the obsolete ‘addValidator’ test suite 7763b20
@Baggz Remove the obsolete ‘errorMessages’ test suite 0c87b5d
@Baggz Remove the obsolete ‘errorObject’ test suite ba55cc0
@Baggz Rewrite the ‘addValidator’ test suite into Mocha 4366cce
@Baggz Added a new test resource ‘percentage’ af54d82
@Baggz Rewrite the ‘UniqueItems’ test suite into Mocha a36e1fc
@Baggz Remove the obsolete ‘test.'s’ file 38db00e
@Baggz Added a compatibility layer c4889d1
@Baggz Updated the ‘README.md’ file 33bae27
@Baggz Add support for a ‘make’ command fbdf02a
@Baggz Fix the ‘date’ test suite faec624
@Baggz Fix a typo in the ‘ip’ test suite 38a7412
@Baggz Fix a typo in the ‘port’ test suite 708070a
@Baggz Update ‘devDependencies’ in the ‘package.json’ file aea598a
@Baggz Rename ‘validators’ to ‘attributes’ 04df899
@Baggz The ‘type’ attribute is now fully compliant with the JSON Schema Inte…
…rnet Draft
172d3ef
@Baggz Move the ‘Validation.prototype.getProperty’ method into a separate file a87600c
@Baggz Move the ‘Validation.prototype.renderErrorMessage’ method into a sepa…
…rate file
c790fd5
@Baggz Move the ‘Validation.prototype.validate’ method into a separate file 250e5e8
@Baggz Move the ‘Validation.prototype.validateItems’ method into a separate …
…file
f965e3f
@Baggz Move the ‘Validation.prototype.validateProperties’ method into a sepa…
…rate file
d1048b1
@Baggz Move the ‘Validation.prototype.validateProperty’ method into a separa…
…te file
f14c194
@Baggz Move the ‘Validation.prototype.validateSchema’ method into a separate…
… file
fd18de5
@Baggz Decouple the ‘Validation’ function into multiple separate files dbc87ee
@Baggz Add a new until ‘isNumber’ f3d9fa5
@Baggz Add a new until ‘isInteger’ 66232a8
@Baggz Add a new until ‘hasProperty’ 2ac8767
@Baggz Add a new until ‘returnTrue’ 9ee638a
@Baggz Attributes are now a prototype of the ‘Validate’ function fb1b2d4
@Baggz Minor improvements of the ‘divisibleBy’ attribute 7a1b3b9
@Baggz Minor improvements to the ‘maxItems’ attribute 637ed6e
@Baggz Minor improvements to the ‘minItems’ 5dc097a
@Baggz Minor improvements to the ‘pattern’ attribute c48d934
@Baggz Minor improvements to the ‘maximum’ attribute 0fcb682
@Baggz Minor improvements to the ‘minimum’ attribute 48e12d2
@Baggz Minor improvements to the ‘minLength’ attribute 09a185d
@Baggz Minor improvements to the ‘maxLength’ attribute 7caf19a
@Baggz Minor improvements to the ‘length’ 93f84a5
@Baggz Move the ‘enum’ attribute into a separate file f0e9c13
@Baggz Move the ‘length’ attribute into a separate file dca2363
@Baggz Move the ‘pattern’ attribute into a separate file f3c8408
@Baggz Move the ‘required’ attribute into a separate file 62d5a6a
@Baggz Move the ‘maximum’ attribute into a separate file ea92433
@Baggz Move the ‘maxItems’ attribute into a separate file 9c3888d
@Baggz Move the ‘maxLength’ attribute into a separate file 62e8881
@Baggz Move the ‘minimum’ attribute into a separate file 22c22bc
@Baggz Move the ‘minItems’ attribute into a separate file 9d0f9bc
@Baggz Move the ‘minLength’ attribute into a separate file a900248
@Baggz Move the ‘divisibleBy’ attribute into a separate file e3577c2
@Baggz Add a new method ‘addAttributeConstructor’ b335e0f
@Baggz Add a new method ‘addAttribute’ 3db3d69
@Baggz Expose the ‘addAttribute’ and the ‘addAttributeConstructor’ methods ea2e62d
@Baggz More detailed error messages 188d118
@Baggz Move attributes into separate files 971a2f0
@Baggz Rename ‘AmandaError’ to ‘ValidationError’ 56a3834
@Baggz Change the way the ‘length’ attribute reports errors 1fc9fb2
@Baggz Change the way the ‘maximum’ attribute reports errors 2423b2d
@Baggz Change the way the ‘maxItems’ attribute reports errors 70e4ac7
@Baggz Change the way the ‘maxLength’ attribute reports errors c4938ce
@Baggz Change the way the ‘minimum’ attribute reports errors 18f3e7e
@Baggz Change the way the ‘minItems’ attribute reports errors e10b82e
@Baggz Change the way the ‘minLength’ attribute reports errors 7d90063
@Baggz Change the way the ‘pattern’ attribute reports errors 6a629ec
@Baggz Change the way the ‘required’ attribute reports errors e7c05ce
@Baggz Change the way the ‘enum’ attribute reports errors 3ffe247
@Baggz Change the way the ‘divisibleBy’ attribute reports errors 8ee2dca
@Baggz Move the ‘type’ attribute into a separate file 4a1a9b8
@Baggz Move the ‘format’ attribute into a separate file 3cabc0c
@Baggz Move the ‘except’ attribute into a separate file c2ea390
@Baggz Move the ‘additionalProperties’ attribute into a separate file 47f7fea
@Baggz Move the ‘additionalItems’ attribute into a separate file a79a212
@Baggz Rename ‘error.js’ to ‘validationError.js’ 37895bd
@Baggz Minor improvements to the ‘Validation’ constructor 3d2f09d
@Baggz Remove the unused ‘validateProperty’ method 0fdf129
@Baggz Expose only certain methods from the validation process cf2eb97
@Baggz Minor improvements to the ‘getProperty’ method a7315e7
@Baggz The ‘validate’ method now accepts JSON 62c719f
@Baggz Add a new utility called ‘every’ b325ab7
@Baggz add a new utility called ‘isBoolean’ 8366eb5
@Baggz add a new utility called ‘isFunction’ c5b277f
@Baggz Add a new utility called ‘isNull’ fdcf0ba
@Baggz Add a new utility called ‘isString’ 131ebb6
@Baggz Add a new utility called ‘isUndefined’ 49448c0
@Baggz Add a new utility called ‘keys’ c92ed73
@Baggz Add a new utility called ‘some’ 53267f4
@Baggz Amanda now exposes the methods of the selected engine f883458
@Baggz Remove the ‘renderErrorMessage’ method 16d4bfa
@Baggz No need to use the ‘new’ keyword in order to initialize Amanda 36dbb63
@Baggz Use the ‘addAttributeConstructor’ method only when necessary 83f0dd1
@Baggz Add support for more formats (‘date’, ‘time’, ‘date-time’, ...) a653c01
@Baggz Fix typos 62a7147
@Baggz Minor improvements to the export of the JSON engine fc62b2d
@Baggz The ‘validate’ method now accepts JSON, properly ba7982d
@Baggz Expose more properties (‘attributes’, ‘errors’, ...) from the validat…
…ion process
1e645e0
@Baggz Removed the ‘int’ format 1845831
@Baggz Removed the ‘unsignedInt’ format c74d068
@Baggz Update the test suite for the ‘ip’ format 63f82c7
@Baggz Fix a typo b6cb573
@Baggz The build script now includes all files f608c9b
@Baggz Remove the ‘objects.js’ files 8d971e7
@Baggz No need to use the ‘call’ method 5a35f54
@Baggz Update the ‘README.md’ file f6b49c5
@Baggz Add a new util called ‘detectType’ e2222dc
@Baggz Update the ‘.travis.yml’ file ad66f7a
@Baggz Add ‘debug’ as a new dependency 123d53f
@Baggz Add ‘async’ as a new dependency 5b393b0
@Baggz Initial implementation of the ‘additionalProperties’ attribute 61d1b77
@Baggz The ‘type’ attribute is now fully compliant with the JSON Schema Inte…
…rnet Draft
9d573be
@Baggz Added a new attribute called ‘patternProperties’ 598afd2
@Baggz Added a new ‘joinPath’ method 8dc87b7
@Baggz Expose the ‘joinPath’ method to the attributes 79fc173
@Baggz Minor improvements to the ‘patternProperties’ attribute e48b427
@Baggz The ‘validateItems’ method now composes a path using the ‘joinPath’ m…
…ethod
9fb4a57
@Baggz The ‘validateProperties’ method now composes a path using the ‘joinPa…
…th’ method
909e9bf
@Baggz Improve the readability of the attributes 4112c6f
@Baggz The ‘divisibleBy’ attribute is now fully compliant with the JSON Sche…
…ma Internet Draft
95ebd82
@Baggz Improve the readability of the ‘maxLength’ attribute dd0ecb5
@Baggz Added a new ‘returnFalse’ util c894b74
@Baggz Add a new ‘dependencies’ attribute b41eb02
@Baggz Add a new ‘isEqual’ util 3745de4
@Baggz Fix the ‘arr1 is not defined’ error 9e31432
@Baggz The ‘uniqueItems’ attribute is now fully compliant with the JSON Sche…
…ma Internet Draft
7772c03
@Baggz The ‘addError’ method has the ability to overwrite the ‘Error’ object 1236ba5
@Baggz Fixed the ‘key is not defined’ error ec161be
@Baggz Better error reporting for the ‘uniqueItems’ attribute dd51353
@Baggz Add a compatibility layer 58da343
@Baggz Improve the readability of the ‘validate’ method 4a2281d
@Baggz The ability to include the ‘domainNames’ resource in a browser 131b8e5
@Baggz The ability to include the ‘domains’ resource in a browser 9f11fdd
@Baggz The ability to include the ‘emails’ resource in a browser 9a4d944
@Baggz The ability to include the ‘params’ resource in a browser 5706ae5
@Baggz The ability to include the ‘percentage’ resource in a browser adf408c
@Baggz Update the ‘README.md’ file e677beb
@Baggz Fix lists in the ‘README.md’ file 81b6192
@Baggz Add a new ‘description’ attribute 9fac4bd
@Baggz Add a new ‘title’ attribute 6d70a90
@Baggz Temporarily removed the ‘additionalItems’ attribute 64d9a6a
@Baggz Add more tests 7ed3f89
@Baggz Add more tests (validation of objects with the ‘singleError’ flag) f5b405f
@Baggz Add more tests (validation of objects without the ‘singleError’ flag) ea39558
@Baggz Add tests for backward compatibility 030f13d
@Baggz Fix a typo in the ‘compatibility.js’ file 21ed8a7
@Baggz Add tests for the ‘addAttribute’ method 24183ec
@Baggz Remove the ‘addValidator.js’ file 1093a54
@Baggz Add more tests (validation of objects) 36880a5
@Baggz Better error reporting for the ‘additionalProperties’ attribute dd7ed49
@Baggz Minor fixes to the ‘type’ attribute f88da1d
@Baggz Fix the ‘apply’ method 8d55426
@Baggz Fix merging of the ‘Options’ object 6cacc83
@Baggz Add tests for the ‘additionalProperties’ attribute fb25075
@Baggz Convert the export variables to lowercase 6e74bc9
@Baggz Add tests for the ‘patternProperties’ attribute 903652c
@Baggz Implement the ‘additionalProperties’ attribute 340d0ab
@Baggz Implement the ‘getProperties’ method 3fcd979
@Baggz Add a compatibility layer to the ‘Error’ object 14db900
@Baggz Implement the ‘renderErrorMessage’ method 132bf6c
@Baggz Initialize the ‘ValidationError’ class as a subclass of the ‘Validati…
…on’ class
cfa1a5e
@Baggz Update the documentation e428d78
@Baggz Update the documentation 67bc291
@Baggz Minor improvements to the ‘except’ attribute a21624a
@Baggz Fix the ‘SyntaxError: <unknown message reserved_word>’ error 0811f2f
@Baggz Remove the ‘md5’ util 8a5bc8f
@Baggz Don't expose the parent object of the ‘ValidationError’ object 87a79bc
@Baggz Add more tests a1c0dd1
@Baggz Add more tests b76eed4
@Baggz Add tests for the ‘required’ attribute 511ddec
@Baggz Add tests for the ‘Error’ object b4fcfdf
@Baggz Update a path to Amanda 2ab9e05
@Baggz Minor improvements to the ‘required’ attribute 0462a56
@Baggz Add a comparison between Amanda and the JSON Schema Internet Draft e90abf1
@Baggz Fix a typo 944be7f
@Baggz Fix the ‘isEmpty’ utility (do not detect a number as an empty object) ea57a43
@Baggz Update the test fot the ‘uniqueItems’ attribute b401d71
@Baggz Minor improvements to the build system 46ccb99
@Baggz Update the ‘package.json’ file f9ba0f3
@Baggz Add the latest release of Amanda 64018ef
@Baggz Update the ‘.travis.yml’ file 7c9c0b2
@Baggz Baggz was assigned
@Baggz Baggz merged commit 01d1e73 into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.