Navel Pondering Mantra

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

    1.0.15 • Public • Published

    Toi's Dynamo

    Build Status codecov

    Toi is a validator for JavaScript values written in TypeScript.

    This is the extra package, where you can find extra validators and transformers useful for working with DynamoDB values.

    It's heavily inspired by Joi, but actually uses different features from TypeScript's type system to infer the output type of a validation schema.

    See the documentation on Toi on GitHub:

    What's up with Dynamo?

    If you've ever seen DynamoDB's values you'll shriek. Amazon tried to do a good job, and let's face it -- JavaScript is terrible with data types -- but the system they chose is weird and difficult to work with. Toi's Dynamo helps with that.

    Toi is a validation chain builder, but it can also transform values in the same steps. Dynamo uses these capabilities to transform (and also validate!) DynamoDB values.

    It turns an object like this:

    const value = {
      M: {
        Null: { NULL: true }, // this is my favorite monstrosity!
        Number: { N: "0.123" },
        String: { S: "Hello, Toi's Dynamo!" },
        Binary: { B: "SGVsbG8sIFRvaSdzIER5bmFtbyE=" },
        Bool: { BOOL: true },
        NumberSet: { NS: ["123", "456"] },
        StringSet: { SS: [ "a", "b" ] }, // really, they had to use "SS"
        BinarySet: { BS: [ "Yq==", "Yg==" }, // it's b.s. !
        ArrayList: { L: [ /* other values here recursively */ ] },
        // ...


    const validator = toi.optional()
        Null: dynamo.isnull(),   // null if null, null if { NULL: true }
        String:, // -> string
        // -> number in JavaScript
        Binary:, // -> Buffer
        Bool:, // -> boolean
        // -> number[] in JavaScript,
        StringSet:, // -> string[]
        BinarySet:, // -> Buffer[]
        ArrayList:, // -> unknown[]

    Additionally it can do validation on the object if you need to use it for schema versioning or similar use cases.


    • Stojan Dimitrovski


    Copyright © 2018 Stojan Dimitrovski et al., some rights reserved.

    Licensed under the MIT license. You can get a copy of it in LICENSE.


    npm i @toi/dynamo

    DownloadsWeekly Downloads






    Unpacked Size

    68.5 kB

    Total Files


    Last publish


    • stdim