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

    13.0.81 • Public • Published


    A typescript library of validators and sanitizers based on validator.js.

    Build Status


    The Typedoc contains documentation for all the validators and sanitizers.


    npm i -S @fireflysemantics/validatorts tslib


    import { isPort } from '@fireflysemantics/validatorts';
    console.log(isPort('4200').value) //Logs true

    Stackblitz Playground

    Error Handling

    In the event of an error the Result.value property will be undefined and both the message and error properties will be set, thus we can handle and error like this:

    if (isPort(4200).error) {
      console.log(isPort(4200).value); //Logs undefined
      console.log(isPort(4200).message); //The error message

    To see what types of errors can occur see the Typedoc for the API being used.

    For more details on the error handling design and approach see Typescript Exception Free Function Error Handling.

    Result API

    Each validator and sanitizer returns a Result instance with this interface:

     * The result of validation and sanitation calls.
    export class Result<E> {
        public message?:string
            public value: E | undefined,
            public error?: MessageFunctionType,
            public parameters?: string[]
        ) { 
            if (error) {
                this.message = this.error!(parameters)

    Build ValidatorTS

    From the project root run npm run b

    Running unit tests

    Run the Jest Tests for ValidatorTS

    npm t

    ValidatorTS Workspace

    This project was generated with Angular CLI version 12.1.2.

    Generate Typedoc

    npm run doc

    Typedoc will be contained in the doc folder of the root directory.

    Supported Package Formats

    The library is built with the Angular Package Format. It therefore supports all these package formats (As can be seen in the provided package.json) and has integrated typescript definitions:

    • "main": "bundles/fireflysemantics-validatorts.umd.js",
    • "module": "fesm5/fireflysemantics-validatorts.js",
    • "es2015": "fesm2015/fireflysemantics-validatorts.js",
    • "esm5": "esm5/fireflysemantics-validatorts.js",
    • "esm2015": "esm2015/fireflysemantics-validatorts.js",
    • "fesm5": "fesm5/fireflysemantics-validatorts.js",
    • "fesm2015": "fesm2015/fireflysemantics-validatorts.js",
    • "typings": "fireflysemantics-validatorts.d.ts",


    npm i @fireflysemantics/validatorts

    DownloadsWeekly Downloads






    Unpacked Size

    1.62 MB

    Total Files


    Last publish


    • ole.ersoy