Fastest Validator Versions Save

:zap: The fastest JS validator library for NodeJS

v1.18.0

3 weeks ago

What's Changed

New Contributors

Full Changelog: https://github.com/icebob/fastest-validator/compare/v1.17.0...v1.18.0

v1.17.0

1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/icebob/fastest-validator/compare/v1.16.0...v1.17.0

v1.16.0

1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/icebob/fastest-validator/compare/v1.15.0...v1.16.0

v1.15.0

1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/icebob/fastest-validator/compare/v1.14.0...v1.15.0

v1.14.0

1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/icebob/fastest-validator/compare/v1.13.0...v1.14.0

v1.13.0

1 year ago

What's Changed

Full Changelog: https://github.com/icebob/fastest-validator/compare/v1.12.0...v1.13.0

v1.12.0

2 years ago

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

2 years ago

Changes

  • fix debug mode. #237
  • fix object "toString" issue. #235
  • remove Node 10 from CI pipeline.
  • refactoring the typescript definitions. #251
  • update examples in readme. #255

v1.11.0

3 years ago

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" }
});

Changes

  • support default and optional in tuples and arrays #226
  • fix that this points to the Validator instance in custom functions #231

v1.10.1

3 years ago

Changes

  • fix issue with regex pattern in string rule #221
  • fix returned value issue in email rule in case of empty: false #224