Skip to content

TypeScript types for joi (Object schema description language and validator for JavaScript objects) https://github.com/hapijs/joi

Notifications You must be signed in to change notification settings

maghis/types-joi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

types-joi

TypeScript definitions for joi (Object schema description language and validator for JavaScript objects) https://joi.dev/

Getting started

Install joi and types-joi:

npm i joi types-joi

Use it:

import * as joi from "types-joi";
import { InterfaceFrom } from "types-joi";

const messageSchema = joi.object({
    status: joi.number().required(),
    body: joi.string()
}).required();

type Message = InterfaceFrom<typeof messageSchema>;

function processMessage(message: Message) {
    if (message.body) message.body.length;
}

const validatedMessage = joi.attempt({ some: "value" }, messageSchema);

processMessage(validatedMessage);

About

TypeScript types for joi (Object schema description language and validator for JavaScript objects) https://github.com/hapijs/joi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages