Skip to content

Commit

Permalink
feat: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yamiteru committed Apr 29, 2024
1 parent 83e3f38 commit 62607f0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ As a result it has many opinions that might not sit well with some folks.

`Validator` is an obsessed overachiever who wants to be the smallest and fastest one on the track.

- 39 `Assertion`s
- 808 bytes bundle
- 40 `Assertion`s
- 835 bytes bundle
- ~ 5x faster data validation than `Zod`
- ~ 200x less memory consumption than `Zod`
- ~ 50x faster type-checking than `Zod`
- 0 runtime dependencies
- 1 runtime dependency
- [@the-minimal/error](https://github.com/the-minimal/error) (135 bytes)
- 100% test coverage

## Simple examples
Expand Down Expand Up @@ -201,7 +202,7 @@ As a result it has many opinions that might not sit well with some folks.
friends: array(string)
});

register("Oh not this is gonna throw");
register("Oh no this is gonna throw");

register({
email: "[email protected]",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"access": "public"
},
"dependencies": {
"@the-minimal/types": "0.4.0"
"@the-minimal/types": "0.4.0",
"@the-minimal/error": "0.1.0"
}
}
14 changes: 14 additions & 0 deletions src/assertions/modulo/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { error } from "@error";
import type { Assertion } from "@the-minimal/types";

/**
* Checks if the remainer is equal to the specified value when the input is divided by the divider.
*
* @param divider - Value used for the division.
* @param remainder - Value that should remain after the division is done.
*
* @example
* ```ts
* const multipleOfTwo = modulo(2, 0);
*
* multipleOfTwo(3); // Error: modulo
* multipleOfTwo(6); // passes
* ```
*/
export const modulo =
(divider: number, remainder: number): Assertion<unknown> =>
(v: unknown) =>
Expand Down
4 changes: 2 additions & 2 deletions src/assertions/or2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { Assertion } from "@the-minimal/types";
*
* If none of them passes it throws an error.
*
* @param brand1 - First assertion to be checked.
* @param brand2 - Second assertion to be checked.
* @param assertion1 - First assertion to be checked.
* @param assertion2 - Second assertion to be checked.
*
* @example
* ```ts
Expand Down
10 changes: 3 additions & 7 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export const error = (cause: unknown, message = "") => {
throw {
name: "Validation",
message,
cause,
};
};
import { error as minimalError } from "@the-minimal/error";

export const error = minimalError("Assertion");

0 comments on commit 62607f0

Please sign in to comment.