Releases: icebob/fastest-validator
Releases · icebob/fastest-validator
v1.19.0
v1.18.0
v1.17.0
What's Changed
- consider null as a value by @Freezystem in #317
- Add type definition for haltOnFirstError on Validator constructor | fix: #316 by @hateablestream in #322
New Contributors
- @Freezystem made their first contribution in #317
Full Changelog: v1.16.0...v1.17.0
v1.16.0
What's Changed
- convert property in array type by @DenisFerrero in #314
New Contributors
- @DenisFerrero made their first contribution in #314
Full Changelog: v1.15.0...v1.16.0
v1.15.0
What's Changed
- fix record rule by @hugebdu in #308
- Using labels in error messages by @Abdullah0sama in #306
New Contributors
- @hugebdu made their first contribution in #308
- @Abdullah0sama made their first contribution in #306
Full Changelog: v1.14.0...v1.15.0
v1.14.0
v1.13.0
What's Changed
- add missing strict by @0x0a0d in #279
- check
empty: true
in string rule. Fixes #283 by @icebob in #284 - fix(date): rule date add convert string to number for timestamp by @intech in #286
- add context.data to d.ts by @0x0a0d in #288
- fix(multi): item rule has custom checker will throw error if validate… by @0x0a0d in #290
- fix: issue #297 by @0x0a0d in #298
- Add Record rule by @FFKL in #300
Full Changelog: v1.12.0...v1.13.0
v1.12.0
Changes
- update dev dependencies.
- add parameters to dynamic default value function. E.g:
age: (schema, field, parent, context) => { ... }
- fix typescript definitions. #269, #270, #261
- fix multi validate with object strict remove. #272
- add
normalize
method. #275 E.g.:validator.normalize({ a: "string[]|optional" })
v1.11.1
v1.11.0
Async custom validator supports
const schema = {
// Turn on async mode for this schema
$$async: true,
name: {
type: "string",
min: 4,
max: 25,
custom: async (v) => {
await new Promise(resolve => setTimeout(resolve, 1000));
return v.toUpperCase();
}
},
username: {
type: "custom",
custom: async (v) => {
// E.g. checking in the DB that whether is unique.
await new Promise(resolve => setTimeout(resolve, 1000));
return v.trim();
}
},
}
The compiled check
function has an async
property to detect this mode. If true
it returns a Promise
.
const check = v.compile(schema);
console.log("Is async?", check.async);
Meta-information for custom validators
You can pass any extra meta information for the custom validators which is available via context.meta
.
const schema = {
name: { type: "string", custom: (value, errors, schema, name, parent, context) => {
// Access to the meta
return context.meta.a;
} },
};
const check = v.compile(schema);
const res = check(obj, {
// Passes meta information
meta: { a: "from-meta" }
});