av's main function is a getter-setter-combo it expects a default value and a validation function the validation function should return the validated value or throw an exception it shouldn't return 'false' for non-validating values
function (i, validate){
  // we offer a shortcut to get types when only one argument is provided
  if (arguments.length === 1) {
    return av.type(i);
  }

  // we store the value in private scope
  var _i;
  // our getter-setter-combo including validation
  var me = function (d){
    if (!arguments.length) {
      if (typeof _i === 'object'){
        var o = {};
        for (var prop in _i){
          o[prop] = _i[prop]();
        }
        return o;
      } else {
        return _i;
      }
    }
    _i = validate(d);
    // if _i is an object we expose the getter/setter methods of its attributes
    if (typeof _i === 'object'){
      for (var prop_object in _i){
        me[prop_object] = _i[prop_object];
      }
    }
  };
  // we initialize the getter-setter-combo with the provided value
  me(i);
  // return the getter-setter-combo (allows chaining, among other things)
  return me;
}