Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Amanda v0.4.0 #35

Merged
merged 304 commits into from Mar 15, 2012

Conversation

Projects
None yet
1 participant
Owner

Baggz commented Mar 14, 2012

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.

Baggz added some commits Mar 7, 2012

@Baggz Baggz Rewrite the ‘maximum’ test into Mocha 05bd651
@Baggz Baggz Rewrite the ‘maxItems’ test into Mocha 6bdaec8
@Baggz Baggz Rewrite the ‘maxLength’ test into Mocha 96b834e
@Baggz Baggz Rewrite the ‘minimum’ test into Mocha 5fcee78
@Baggz Baggz Rewrite the ‘minItems’ test into Mocha 339d90c
@Baggz Baggz Rewrite the ‘minLength’ test into Mocha 2998b66
@Baggz Baggz Rewrite the ‘pattern’ test into Mocha 3d6507f
@Baggz Baggz Rewrite the ‘array’ test into Mocha f686111
@Baggz Baggz Rewrite the ‘boolean’ test into Mocha b831ef1
@Baggz Baggz Rewrite the ‘function’ test into Mocha d1ef558
@Baggz Baggz Rewrite the ‘number’ test into Mocha f58b92f
@Baggz Baggz Rewrite the ‘object’ test into Mocha e10f95d
@Baggz Baggz Rewrite the ‘string’ test into Mocha d1b805e
@Baggz Baggz Rewrite the ‘alpha’ test into Mocha 206fe94
@Baggz Baggz Rewrite the ‘alphanumeric’ test into Mocha 388d248
@Baggz Baggz Rewrite the ‘decimal’ test into Mocha 0b565d3
@Baggz Baggz Rewrite the ‘email’ test into Mocha 0943172
@Baggz Baggz Rewrite the ‘date’ test into Mocha bd76af6
@Baggz Baggz Rewrite the ‘int’ test into Mocha 17c2a8a
@Baggz Baggz Rewrite the ‘ip’ test into Mocha 4ab593d
@Baggz Baggz Rewrite the ‘port’ test into Mocha d158699
@Baggz Baggz Remove the obsolete ‘maximum’ test d8a7691
@Baggz Baggz Remove the obsolete ‘maxItems’ test suite f1ced5f
@Baggz Baggz Remove the obsolete ‘minItems’ test suite 2dc56ea
@Baggz Baggz Remove the obsolete ‘minimum’ test suite 99373b4
@Baggz Baggz Remove the obsolete ‘maxLength’ test suite ce6d936
@Baggz Baggz Remove the obsolete ‘minLength’ test suite 4f4fade
@Baggz Baggz Remove the obsolete ‘exclusiveMaximum’ test suite 76810a5
@Baggz Baggz Remove the obsolete ‘exclusiveMinimum’ test suite 2b5750f
@Baggz Baggz Remove the obsolete ‘alpha’ test suite 0cd0f05
@Baggz Baggz Remove the obsolete ‘alphanumeric’ test suite c33270d
@Baggz Baggz Remove the obsolete ‘date’ test suite 45f85a6
@Baggz Baggz Remove the obsolete ‘decimal’ test suite 4d91902
@Baggz Baggz Remove the obsolete ‘email’ test suite b4d19d5
@Baggz Baggz Remove the obsolete ‘int’ test suite 9ae27ae
@Baggz Baggz Remove the obsolete ‘ip’ test suite 39d4ab6
@Baggz Baggz Remove the obsolete ‘enum’ test suite 77030b0
@Baggz Baggz Remove the obsolete ‘except’ test suite 63c9e10
@Baggz Baggz Remove the obsolete ‘divisibleBy’ test suite c2d64de
@Baggz Baggz Remove the obsolete ‘length’ test suite dd1c082
@Baggz Baggz Remove the obsolete ‘pattern’ test suite f277eb3
@Baggz Baggz Remove the obsolete ‘array’ test suite a112ade
@Baggz Baggz Remove the obsolete ‘boolean’ test suite 27e3152
@Baggz Baggz Remove the obsolete ‘function’ test suite b39aed0
@Baggz Baggz Remove the obsolete ‘number’ test suite b3e2d8a
@Baggz Baggz Remove the obsolete ‘object’ test suite 443d1f3
@Baggz Baggz Remove the obsolete ‘string’ test suite bd41e0c
@Baggz Baggz Remove the obsolete ‘uniqueItems’ test suite 273dcf4
@Baggz Baggz Remove the obsolete ‘port’ test suite c7abada
@Baggz Baggz Removed the ‘amanda.min.js’ file 560146a
@Baggz Baggz Remove the obsolete ‘percentage’ test suite 3fb8e5e
@Baggz Baggz Remove the obsolete ‘regex’ test suite bedc642
@Baggz Baggz Remove the obsolete ‘unsignedInt’ test suite b3d327a
@Baggz Baggz Remove the obsolete ‘url’ test suite 11b4dcc
@Baggz Baggz Rewrite the ‘percentage’ test suite into Mocha c731609
@Baggz Baggz Rewrite the ‘regex’ test suite into Mocha 57ae3b9
@Baggz Baggz Rewrite the ‘unsignedInt’ test suite into Mocha 04d5978
@Baggz Baggz Rewrite the ‘url’ test suite into Mocha fb46f77
@Baggz Baggz Added a new test resource ‘domainNames’ 28e45f8
@Baggz Baggz Added a new test resource ‘domains’ bb2d254
@Baggz Baggz Added a new test resource ‘emails’ 61efc12
@Baggz Baggz Added a new test resource ‘params’ b40854f
@Baggz Baggz Remove the obsolete ‘Arrays’ test suite 3fad3cb
@Baggz Baggz Remove the obsolete ‘ArraysSingleError’ test suite 05c4582
@Baggz Baggz Remove the obsolete ‘mixed’ test suite 02b8321
@Baggz Baggz Remove the obsolete ‘MixedSingleError’ test suite f67fabe
@Baggz Baggz Remove the obsolete ‘MultipleValidators’ test suite 8a5b5fb
@Baggz Baggz Remove the obsolete ‘Objects’ test suite 19a67d4
@Baggz Baggz Remove the obsolete ‘ObjectsSingleError’ test suite 4692b20
@Baggz Baggz Remove the obsolete ‘Objects’ test suite f881ec4
@Baggz Baggz Remove the obsolete ‘ObjectsSingleError’ test suite 59f5ebb
@Baggz Baggz Remove the obsolete ‘Required’ test suite 1932d25
@Baggz Baggz Remove the obsolete ‘addValidator’ test suite 7763b20
@Baggz Baggz Remove the obsolete ‘errorMessages’ test suite 0c87b5d
@Baggz Baggz Remove the obsolete ‘errorObject’ test suite ba55cc0
@Baggz Baggz Rewrite the ‘addValidator’ test suite into Mocha 4366cce
@Baggz Baggz Added a new test resource ‘percentage’ af54d82
@Baggz Baggz Rewrite the ‘UniqueItems’ test suite into Mocha a36e1fc
@Baggz Baggz Remove the obsolete ‘test.'s’ file 38db00e
@Baggz Baggz Added a compatibility layer c4889d1
@Baggz Baggz Updated the ‘README.md’ file 33bae27
@Baggz Baggz Add support for a ‘make’ command fbdf02a
@Baggz Baggz Fix the ‘date’ test suite faec624
@Baggz Baggz Fix a typo in the ‘ip’ test suite 38a7412
@Baggz Baggz Fix a typo in the ‘port’ test suite 708070a
@Baggz Baggz Update ‘devDependencies’ in the ‘package.json’ file aea598a
@Baggz Baggz Rename ‘validators’ to ‘attributes’ 04df899
@Baggz Baggz The ‘type’ attribute is now fully compliant with the JSON Schema Inte…
…rnet Draft
172d3ef
@Baggz Baggz Move the ‘Validation.prototype.getProperty’ method into a separate file a87600c
@Baggz Baggz Move the ‘Validation.prototype.renderErrorMessage’ method into a sepa…
…rate file
c790fd5
@Baggz Baggz Move the ‘Validation.prototype.validate’ method into a separate file 250e5e8
@Baggz Baggz Move the ‘Validation.prototype.validateItems’ method into a separate …
…file
f965e3f
@Baggz Baggz Move the ‘Validation.prototype.validateProperties’ method into a sepa…
…rate file
d1048b1
@Baggz Baggz Move the ‘Validation.prototype.validateProperty’ method into a separa…
…te file
f14c194
@Baggz Baggz Move the ‘Validation.prototype.validateSchema’ method into a separate…
… file
fd18de5
@Baggz Baggz Decouple the ‘Validation’ function into multiple separate files dbc87ee
@Baggz Baggz Add a new until ‘isNumber’ f3d9fa5
@Baggz Baggz Add a new until ‘isInteger’ 66232a8
@Baggz Baggz Add a new until ‘hasProperty’ 2ac8767
@Baggz Baggz Add a new until ‘returnTrue’ 9ee638a

Baggz added some commits Mar 12, 2012

@Baggz Baggz Add a new utility called ‘isNull’ fdcf0ba
@Baggz Baggz Add a new utility called ‘isString’ 131ebb6
@Baggz Baggz Add a new utility called ‘isUndefined’ 49448c0
@Baggz Baggz Add a new utility called ‘keys’ c92ed73
@Baggz Baggz Add a new utility called ‘some’ 53267f4
@Baggz Baggz Amanda now exposes the methods of the selected engine f883458
@Baggz Baggz Remove the ‘renderErrorMessage’ method 16d4bfa
@Baggz Baggz No need to use the ‘new’ keyword in order to initialize Amanda 36dbb63
@Baggz Baggz Use the ‘addAttributeConstructor’ method only when necessary 83f0dd1
@Baggz Baggz Add support for more formats (‘date’, ‘time’, ‘date-time’, ...) a653c01
@Baggz Baggz Fix typos 62a7147
@Baggz Baggz Minor improvements to the export of the JSON engine fc62b2d
@Baggz Baggz The ‘validate’ method now accepts JSON, properly ba7982d
@Baggz Baggz Expose more properties (‘attributes’, ‘errors’, ...) from the validat…
…ion process
1e645e0
@Baggz Baggz Removed the ‘int’ format 1845831
@Baggz Baggz Removed the ‘unsignedInt’ format c74d068
@Baggz Baggz Update the test suite for the ‘ip’ format 63f82c7
@Baggz Baggz Fix a typo b6cb573
@Baggz Baggz The build script now includes all files f608c9b
@Baggz Baggz Remove the ‘objects.js’ files 8d971e7
@Baggz Baggz No need to use the ‘call’ method 5a35f54
@Baggz Baggz Update the ‘README.md’ file f6b49c5
@Baggz Baggz Add a new util called ‘detectType’ e2222dc
@Baggz Baggz Update the ‘.travis.yml’ file ad66f7a
@Baggz Baggz Add ‘debug’ as a new dependency 123d53f
@Baggz Baggz Add ‘async’ as a new dependency 5b393b0
@Baggz Baggz Initial implementation of the ‘additionalProperties’ attribute 61d1b77
@Baggz Baggz The ‘type’ attribute is now fully compliant with the JSON Schema Inte…
…rnet Draft
9d573be
@Baggz Baggz Added a new attribute called ‘patternProperties’ 598afd2
@Baggz Baggz Added a new ‘joinPath’ method 8dc87b7
@Baggz Baggz Expose the ‘joinPath’ method to the attributes 79fc173
@Baggz Baggz Minor improvements to the ‘patternProperties’ attribute e48b427
@Baggz Baggz The ‘validateItems’ method now composes a path using the ‘joinPath’ m…
…ethod
9fb4a57
@Baggz Baggz The ‘validateProperties’ method now composes a path using the ‘joinPa…
…th’ method
909e9bf
@Baggz Baggz Improve the readability of the attributes 4112c6f
@Baggz Baggz The ‘divisibleBy’ attribute is now fully compliant with the JSON Sche…
…ma Internet Draft
95ebd82
@Baggz Baggz Improve the readability of the ‘maxLength’ attribute dd0ecb5
@Baggz Baggz Added a new ‘returnFalse’ util c894b74
@Baggz Baggz Add a new ‘dependencies’ attribute b41eb02
@Baggz Baggz Add a new ‘isEqual’ util 3745de4
@Baggz Baggz Fix the ‘arr1 is not defined’ error 9e31432
@Baggz Baggz The ‘uniqueItems’ attribute is now fully compliant with the JSON Sche…
…ma Internet Draft
7772c03
@Baggz Baggz The ‘addError’ method has the ability to overwrite the ‘Error’ object 1236ba5
@Baggz Baggz Fixed the ‘key is not defined’ error ec161be
@Baggz Baggz Better error reporting for the ‘uniqueItems’ attribute dd51353
@Baggz Baggz Add a compatibility layer 58da343
@Baggz Baggz Improve the readability of the ‘validate’ method 4a2281d
@Baggz Baggz The ability to include the ‘domainNames’ resource in a browser 131b8e5
@Baggz Baggz The ability to include the ‘domains’ resource in a browser 9f11fdd
@Baggz Baggz The ability to include the ‘emails’ resource in a browser 9a4d944
@Baggz Baggz The ability to include the ‘params’ resource in a browser 5706ae5
@Baggz Baggz The ability to include the ‘percentage’ resource in a browser adf408c
@Baggz Baggz Update the ‘README.md’ file e677beb
@Baggz Baggz Fix lists in the ‘README.md’ file 81b6192
@Baggz Baggz Add a new ‘description’ attribute 9fac4bd
@Baggz Baggz Add a new ‘title’ attribute 6d70a90
@Baggz Baggz Temporarily removed the ‘additionalItems’ attribute 64d9a6a
@Baggz Baggz Add more tests 7ed3f89
@Baggz Baggz Add more tests (validation of objects with the ‘singleError’ flag) f5b405f
@Baggz Baggz Add more tests (validation of objects without the ‘singleError’ flag) ea39558
@Baggz Baggz Add tests for backward compatibility 030f13d
@Baggz Baggz Fix a typo in the ‘compatibility.js’ file 21ed8a7
@Baggz Baggz Add tests for the ‘addAttribute’ method 24183ec
@Baggz Baggz Remove the ‘addValidator.js’ file 1093a54
@Baggz Baggz Add more tests (validation of objects) 36880a5
@Baggz Baggz Better error reporting for the ‘additionalProperties’ attribute dd7ed49
@Baggz Baggz Minor fixes to the ‘type’ attribute f88da1d
@Baggz Baggz Fix the ‘apply’ method 8d55426
@Baggz Baggz Fix merging of the ‘Options’ object 6cacc83
@Baggz Baggz Add tests for the ‘additionalProperties’ attribute fb25075
@Baggz Baggz Convert the export variables to lowercase 6e74bc9
@Baggz Baggz Add tests for the ‘patternProperties’ attribute 903652c
@Baggz Baggz Implement the ‘additionalProperties’ attribute 340d0ab
@Baggz Baggz Implement the ‘getProperties’ method 3fcd979
@Baggz Baggz Add a compatibility layer to the ‘Error’ object 14db900
@Baggz Baggz Implement the ‘renderErrorMessage’ method 132bf6c
@Baggz Baggz Initialize the ‘ValidationError’ class as a subclass of the ‘Validati…
…on’ class
cfa1a5e
@Baggz Baggz Update the documentation e428d78
@Baggz Baggz Update the documentation 67bc291
@Baggz Baggz Minor improvements to the ‘except’ attribute a21624a
@Baggz Baggz Fix the ‘SyntaxError: <unknown message reserved_word>’ error 0811f2f
@Baggz Baggz Remove the ‘md5’ util 8a5bc8f
@Baggz Baggz Don't expose the parent object of the ‘ValidationError’ object 87a79bc
@Baggz Baggz Add more tests a1c0dd1
@Baggz Baggz Add more tests b76eed4
@Baggz Baggz Add tests for the ‘required’ attribute 511ddec
@Baggz Baggz Add tests for the ‘Error’ object b4fcfdf
@Baggz Baggz Update a path to Amanda 2ab9e05
@Baggz Baggz Minor improvements to the ‘required’ attribute 0462a56
@Baggz Baggz Add a comparison between Amanda and the JSON Schema Internet Draft e90abf1
@Baggz Baggz Fix a typo 944be7f
@Baggz Baggz Fix the ‘isEmpty’ utility (do not detect a number as an empty object) ea57a43
@Baggz Baggz Update the test fot the ‘uniqueItems’ attribute b401d71
@Baggz Baggz Minor improvements to the build system 46ccb99
@Baggz Baggz Update the ‘package.json’ file f9ba0f3
@Baggz Baggz Add the latest release of Amanda 64018ef
@Baggz Baggz Update the ‘.travis.yml’ file 7c9c0b2

@Baggz Baggz was assigned Mar 15, 2012

@Baggz Baggz merged commit 01d1e73 into master Mar 15, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment