npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thzero/library_server_validation_joi

v0.19.1

Published

![GitHub package.json version](https://img.shields.io/github/package-json/v/thzero/library_server_validation_joi) ![David](https://img.shields.io/david/thzero/library_server_validation_joi) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.

Readme

GitHub package.json version David License: MIT

library_server_validation_joi

The Joi backed validation service for @thzero/library_server.

Implements the framework's validation contract and ships the schemas the library's own services validate against, so an application only writes schemas for its own entities.

Requirements

NodeJs

NodeJs version 22+

Installation

NPM

npm install @thzero/library_server_validation_joi

Peer dependencies

  • @thzero/library_common
  • @thzero/library_common_service
  • @thzero/library_server

@joi/date is registered onto Joi by this package, so Joi.date().format(...) is available to your schemas too.

What it provides

index.jsJoiBaseValidationService

| Method | Purpose | |---|---| | check(correlationId, schema, value, context, prefix) | Validates value against schema. Returns a success response, or an error response with one entry per failing field. context is passed to Joi as its options — { allowUnknown: true }, for example. | | _validateError(correlationId, error, prefix) | Turns a Joi error into the framework's error response. Each detail is also logged as a warning against the correlationId. |

check reports only the error. Joi's coerced value is not returned, so a schema that trims or casts does not hand the cleaned value back to the caller — validate, then use your own value.

Reusable field schemas

Building blocks for an application's own schemas, all protected members:

_boolean, _dateIso, _description, _email, _extendedName, _extendedNameBase, _externalId, _id, _name, _nameLong, _number, _roles, _tagLine, _timestamp, _url, _usageMetricsMeasurementType, _username, _userpicture

_id matches the framework's generated id shape — 20 to 30 characters of A-Za-z0-9_-.

Entity schemas

| Schema | Used for | |---|---| | idSchema, externalIdSchema, nameSchema | Single-value checks | | externalUserSchema | The user as the identity provider supplies it — id required, name, email and picture nullable | | userSchema, userUpdateSchema | Users. userUpdateSchema requires updatedTimestamp, which is what drives the framework's concurrency check | | settingsRefreshSchema, settingRequestSchema(), settingSchema() | User settings. Override settingSchema() to describe your application's settings | | usageMetricsMeasurementTag, usageMetricsMeasurementTagParams, usageMetricsMeasurementTagParamsSort | Usage metrics |

news/index.jsBaseNewsJoiBaseValidationService

Adds the news schemas: getNewsSchema, getNewsUpdateSchema, getNewStatus, getNewsTypes.

gamer.jsGamerJoiValidationService

Adds gamer tag schemas: settingGamerTagSchema, settingGamerTagDisplaySchema, settingGamerTagSearchSchema, and a settingSchema override.

Configuration

None. This package reads no configuration.

Wiring it up

Subclass it, add your schemas, and register the subclass under SERVICE_VALIDATION:

import JoiBaseValidationService from '@thzero/library_server_validation_joi/index.js';

class AppValidationService extends JoiBaseValidationService {
    partSchema = Joi.object({
        id: this._id.required(),
        name: this._name.required(),
        manufacturerId: this._id.allow(null)
    });

    settingSchema() {
        return Joi.object({ measurementUnits: Joi.string().allow(null) });
    }
}

Then use it from a service:

const validationResponse = this._serviceValidation.check(correlationId, this._serviceValidation.partSchema, part);
if (this._hasFailed(validationResponse))
    return validationResponse;

The framework's own services resolve SERVICE_VALIDATION and expect the library schemas above to be present, so subclass rather than replace.

Development

npm run lint       # eslint .
npm run lint:fix   # eslint . --fix
npm test           # node --test "test/*.test.js"