Skip to content

Commit

Permalink
[ci] release (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and github-actions[bot] authored Jul 4, 2024
1 parent 0693709 commit 539d22f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 78 deletions.
77 changes: 0 additions & 77 deletions .changeset/chatty-vans-shout.md

This file was deleted.

81 changes: 81 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,86 @@
# ajv-ts

## 0.7.0

### Minor Changes

- 3e6636b: This release contains new cool features.

## New features

- extend `error` method for map custom messages(#54). Originally works from ajv-errors and examples from this docs are works
examples:

```ts
import s from "ajv-ts";

const s1 = s.string().error({ _: "any error here" });

s.parse(123); // throws "any error here"

s.string().error({ _: "any error here", type: "not a string. Custom" });

s.parse(123); // throws "not a string. Custom"

const Obj = s
.object({ foo: s.string() })
.strict()
.error({ additionalProperties: "Not expected to pass additional props" });

Obj.parse({ foo: "ok", bar: true }); // throws "Not expected to pass additional props"
```

One more example:

```ts
const Schema = s
.object({
foo: s.integer().minimum(2),
bar: s.string().minLength(2),
})
.strict()
.error({
properties: {
foo: "data.foo should be integer >= 2",
bar: "data.bar should be string with length >= 2",
},
});
Schema.parse({ foo: 1, bar: "a" }); // throws: "data.foo should be integer >= 2"
```

- check length for `string` and `array` schema. Example:

```ts
import s from "ajv-ts";
s.string().minLength(3).maxLength(1); // error. MaxLength < MinLength

s.array().minLength(4).maxLength(2); // error. MaxLength < MinLength

s.string().length(-1); // error. Length is negative
```

- `fromJSON` can eval incoming JSON(or object) and "attach" into schema.
example:

```ts
import s from "ajv-ts";
const externalSchema = s.fromJSON(
{ someProp: "YesImCustomProp", type: "number" },
s.string()
);
externalSchema.schema.someProp === "YesImCustomProp"; // true
externalSchema.schema.type === "number"; // true
```

## Fixes

- issue with `merge` when old schema(before modified with `merge` function) schema was applies

## Infra

- migrate from bun to pnpm package manager
- update PR steps. Now we use bun@latest, pnpm@9 with node@18, node@20 and node@22 versions.

## 0.6.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ajv-ts",
"description": "JSON-schema builder with typescript safety",
"version": "0.6.3",
"version": "0.7.0",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit 539d22f

Please sign in to comment.