v0.83 (2009-12-06)
==================
Features
- RestApiConfigSecurityHandler can now use a FieldValidator for access rights validation.
- Added RestApiValidationException, to be used when data validation fails.
- Added standard regexps in haxigniter.common.validation.Field.
Changed
- RestApiConfigSecurityHandler now uses a password encoder function in the "userPasswordEncoder" property,
that will be applied on the password before checking the database. Default is MD5.
- Better error logging for exceptions derived from haxigniter.common.exceptions.Exception
- FieldValidator callbacks (ValidationCallback) should return the new value or null for failed validation.
- No foreign keys can be written to in RestApiConfigSecurityHandler unless stated explicitly.
- RestApiHandler now accepts requests without api version.
- RestApiHandler now takes the requested format at the end of the query (/resource/1.xml for example)
- RestApiHandler can now be created without a RestApiSecurityHandler. The security handler will bypass
its own security with this method, to avoid a circular reference.
- haxigniter.server.libraries.DatabaseConnection now logs sql errors instead of tracing them.
Bug fixes
- In write requests, RestApiSqlRequestHandler now uses the foreign key if it exists in the input data.
- Data in RestApiSqlRequestHandler is now modified properly by FieldValidator callbacks.
- Fixed a path bug in run.n.
The RestApi has been taken on a more serious test spin, so this is mostly a bugfix release for it, but there are also some FieldValidator goodies added. Note that the FieldValidator is cross-platform, so it's intended to validate user data both on server and client. Here's a simple usage example:
static var userValidation = { email: Field.email(),
password: Field.anythingOneline(5), // Minimum 5 characters
created: ~/^\d{4}-\d{2}-\d{2}$/
};static var userValidationCallbacks = {
password: function(input : String) { return haxe.Md5.encode(input);
}};
The userValidation is normal regexp validation, but the callbacks object modifies the input data (or return null if it should fail), in this case it hashes the password to MD5.
var v = new FieldValidator(userValidation, userValidationCallbacks);
v.validate({email: "te...@testing.com", password: ... });The return value from validate() is one of these:
enum ValidationResult{
success; tooMany(extraFields : List<String>);
tooFew(missingFields : List<String>); failure(fields : List<String>);
}Which is quite simple to hook up to your own javascript input validator, or something on the server-side. Hope you'll find some good use for it!
/Andreas