This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
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:
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:
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:
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:
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
ajv-ts@0.7.0
Minor Changes
3e6636b: This release contains new cool features.
New features
error
method for map custom messages(#54). Originally works from ajv-errors and examples from this docs are works examples:One more example:
string
andarray
schema. Example:fromJSON
can eval incoming JSON(or object) and "attach" into schema. example:Fixes
merge
when old schema(before modified withmerge
function) schema was appliesInfra