via-type v0.2.2
Via-Type
Description
Simple type interfaces.
Install
npm install
gulp build.nodeAPI
String
new StringType(options: DocumentOptions);export interface StringOptions {
regex?: RegExp; // null
lowerCase?: boolean; // false
trimmed?: boolean; // false
minLength?: number; // null
maxLength?: number; // null
looseTest?: boolean; // false
}looseTest: The test returns true if the only errors found can be fixed with .normalize.
.test(options: StringOptions)
Tests whether a string is valid or not according to the options.
Document
new DocumentType(options: DocumentOptions);Creates a new type to match against documents. This type ensures that the defined properties are set, enumerable and valid.
DocumentOptions:
properties: Dictionary<PropertyDescriptor>: Each key is used as the property name and the associated behaviour is determined by the associatedPropertyDescriptor. If the value isnull, then the property is deleted (ignored) - usefull when extending theDocumentOptions.PropertyDescriptor:type: Type: the type of the property (soon: If the type isnull-> allow any value, requires manual read/write)optional: boolean: Allows the value to benull
additionalProperties: boolean: Allow (and ignore) additional properties when doing tests
.diff
interface DiffResult {
$set: Dictionary<jsonValues>;
$update: Dictionary<Diff>;
$unset: Dictionary<jsonValues>;
}