Created definitions for 'tv4'

https://github.com/geraintluff/tv4
This commit is contained in:
Bart van der Schoor
2014-01-27 03:34:54 +01:00
parent bbbca02b99
commit 3fff40427e
3 changed files with 91 additions and 0 deletions
+1
View File
@@ -235,6 +235,7 @@ List of Definitions
* [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/))
* [Swiper](http://www.idangero.us/sliders/swiper) (by [Sebastián Galiano](https://github.com/sgaliano))
* [SwipeView](http://cubiq.org/swipeview) (by [Boris Yankov](https://github.com/borisyankov))
* [TV4](https://github.com/geraintluff/tv4) (by [Bart van der Schoor](https://github.com/Bartvds))
* [Tags Manager](http://welldonethings.com/tags/manager) (by [Vincent Bortone](https://github.com/vbortone))
* [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com))
* [three.js](http://mrdoob.github.com/three.js/) (by [Kon](http://phyzkit.net/))
+43
View File
@@ -0,0 +1,43 @@
///<reference path="tv4.d.ts" />
var str:string;
var strArr:string[];
var bool:boolean;
var num:number;
var obj:any;
var tv4:TV4;
var err:TV4Error;
var errs:TV4Error[];
var single:TV4SingleResult;
var multi:TV4MultiResult;
single = tv4.validateResult(obj, obj);
bool = single.valid;
strArr = single.missing;
err = single.error;
num = err.code;
str = err.message;
str = err.dataPath;
str = err.schemaPath;
multi = tv4.validateMultiple(obj, obj);
bool = multi.valid;
strArr = multi.missing;
errs = multi.errors;
bool = tv4.addSchema(str, obj);
obj = tv4.getSchema(str);
obj = tv4.normSchema(str, str);
str = tv4.resolveUrl(str, str);
tv4 = tv4.freshApi();
tv4.dropSchemas();
tv4.reset();
strArr = tv4.getMissingUris(/abc/);
strArr = tv4.getSchemaUris(/abc/);
obj = tv4.getSchemaMap()[str];
num = tv4.errorCodes['bla'];
num = tv4.errorCodes['MY_NAME'];
+47
View File
@@ -0,0 +1,47 @@
// Type definitions for Tiny Validator tv4 1.0.6
// Project: https://github.com/geraintluff/tv4
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface TV4ErrorCodes {
[key:string]:number;
}
interface TV4Error {
code:number;
message:string;
dataPath:string;
schemaPath:string;
}
interface TV4SchemaMap {
[uri:string]:any;
}
interface TV4BaseResult {
missing:string[];
valid:boolean;
}
interface TV4SingleResult extends TV4BaseResult {
error:TV4Error;
}
interface TV4MultiResult extends TV4BaseResult {
errors:TV4Error[];
}
interface TV4 {
validateResult(data:any, schema:any):TV4SingleResult;
validateMultiple(data:any, schema:any):TV4MultiResult;
addSchema(uri:string, schema:any):boolean;
getSchema(uri:string):any;
normSchema(schema:any, baseUri:string):any;
resolveUrl(base:string, href:string):string;
freshApi():TV4;
dropSchemas():void;
reset():void;
getMissingUris(exp?:RegExp):string[];
getSchemaUris(exp?:RegExp):string[];
getSchemaMap():TV4SchemaMap;
errorCodes:TV4ErrorCodes;
}
declare module "tv4" {
export = TV4;
}