Neolithic Programming Machine

    via-type
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.2 • Public • Published

    Via-Type

    Description

    Simple type interfaces.

    Install

    npm install
    gulp build.node

    API

    String

    new StringType(optionsDocumentOptions);
    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(optionsDocumentOptions);

    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 associated PropertyDescriptor. If the value is null, then the property is deleted (ignored) - usefull when extending the DocumentOptions.

      PropertyDescriptor:

      • type: Type: the type of the property (soon: If the type is null -> allow any value, requires manual read/write)

      • optional: boolean: Allows the value to be null

    • additionalProperties: boolean: Allow (and ignore) additional properties when doing tests

    .diff

    interface DiffResult {
        $set: Dictionary<jsonValues>;
        $update: Dictionary<Diff>;
        $unset: Dictionary<jsonValues>;
    }

    Keywords

    Install

    npm i via-type

    DownloadsWeekly Downloads

    5

    Version

    0.2.2

    License

    MIT

    Last publish

    Collaborators

    • demurgos