Just for a guy who wants to survive in a massive, legacy JavaScript/TypeScript codebase.
- 💪 JavaScript version of TypeScript + Zod: Ditch any & complexity.
- 💣 No vender lock-in.
- 🐛 Find bug quickly.
- ❤️🔥 DX first, DX first, DX first and security!
- 🪶 3.65 kB (minified + gzipped), 0 dependencies.
- ✅ Autocompletion support.
- ⚡ (Optional) The definitive choice for high-performance.

source: ESTest-benchmark-repo
npm add escss-estest
- Core Concept
- Core API
- ESTest
- unSafeESTest
- Usage is exactly the same as ESTest
- ESTestForLibrary
- Usage is exactly the same as ESTest
- Helper API
- Thanks
ESTest
: console.error --> decoupling / isESTestDisabled = true for high-performanceunSafeESTest
: throw new ErrorESTestForLibrary
: The default message is separated fromESTest
&unSafeESTest
import { ESTest } from "escss-estest";
function sum(a, b) {
{
// validate type
ESTest(a, "number");
ESTest(b, "number");
}
// do something
}
import { ESTest } from "escss-estest";
async function getApi() {
const apiData = await fetch("https://jsonplaceholder.typicode.com/todos/1");
const data = await apiData.json();
// const data = {
// id: 1,
// name: 'Mike',
// info: {
// title: "developer",
// more: [
// {
// msg: 'Hello!',
// },
// {
// msg: 'Hi!',
// }
// ]
// },
// }
{
// validate schema
ESTest(data, "object", "schema mismatch").schema({
id: "number",
"name?": "string",
info: {
title: "string",
more: [
{
msg: "string",
},
],
},
});
// validate detail
ESTest(data.id, "number", "custom msg").min(0).max(50);
}
// do something
}
getApi();
Usage is exactly the same as ESTest
import { unSafeESTest } from "escss-estest";
import express from "express";
const app = express();
const port = 3000;
app.use(express.json());
app.post("/demo", (req, res) => {
try {
const data = req.body;
// const data = {
// id: 1,
// name: 'Mike',
// info: {
// title: "developer",
// more: [
// {
// msg: 'Hello!',
// },
// {
// msg: 'Hi!',
// }
// ]
// },
// }
{
// validate schema
ESTest(data, "object", "schema mismatch").schema({
id: "number",
"name?": "string",
info: {
title: "string",
more: [
{
msg: "string",
},
],
},
});
// validate detail
unSafeESTest(data.id, "number", "custom msg").min(0).max(50);
}
// do something
res.json({ message: "ok" });
} catch (err) {
res.status(400).json({ message: err.message });
}
});
app.listen(port, () => {
console.log(`http://localhost:${port}`);
});
Library's own default message
import { ESTestForLibrary } from "escss-estest";
function ESTest(
input,
type,
message = "[LibraryName] default message for others to help debugging",
) {
return ESTestForLibrary(input, type, message);
}
- Show information

- Set default message for your project.
globalThis.__ESCSS_ESTEST__.message = "Please report this issue to ...";
true
: Disable to get high-performance. (for production)false
: Show Bug detail.
Note: unSafeESTest
will not be affected (for security reasons)
globalThis.__ESCSS_ESTEST__.isESTestDisabled = true;
function sum(a, b) {
{
ESTest(a, "number");
ESTest(b, "number");
}
return a + b;
}
// same as
function sum(a, b) {
return a + b;
}
- Show usage reports
