Socket
Socket
Sign inDemoInstall

fastest-validator

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastest-validator - npm Package Versions

23
6

1.19.0

Diff

icebob
published 1.18.0 •

Changelog

Source

1.18.0 (2024-04-21)

Changes

  • improve typing. #339
  • allow to add metas in the schema. #341

<a name="1.17.0"></a>

icebob
published 1.17.0 •

Changelog

Source

1.17.0 (2023-04-23)

Changes

  • add considerNullAsAValue to Validation constructor options. #317
  • add type definition for haltOnFirstError on Validator constructor. #322

<a name="1.16.0"></a>

icebob
published 1.16.0 •

Changelog

Source

1.16.0 (2022-12-17)

Changes

  • add convert to array rule. #314

<a name="1.15.0"></a>

icebob
published 1.15.0 •

Changelog

Source

1.15.0 (2022-08-30)

Changes

<a name="1.14.0"></a>

icebob
published 1.14.0 •

Changelog

Source

1.14.0 (2022-08-27)

Changes

  • fix: Multi-schema nullable validators not working as expected. #303
  • add new haltOnFirstError option (https://github.com/icebob/fastest-validator#halting). #304

<a name="1.13.0"></a>

icebob
published 1.13.0 •

Changelog

Source

1.13.0 (2022-08-15)

Changes

  • update dev dependencies.
  • update d.ts
  • fixing string enum check in case of optional field. #284
  • date rule add convert string to number for timestamp. #286
  • fix(multi): item rule has custom checker will throw error if validate. #290
  • fix backward compatibility issue. #298
  • add new Record rule. #300

<a name="1.12.0"></a>

icebob
published 1.12.0 •

Changelog

Source

1.12.0 (2021-10-17)

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

<a name="1.11.1"></a>

icebob
published 1.11.1 •

Changelog

Source

1.11.1 (2021-07-14)

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

<a name="1.11.0"></a>

icebob
published 1.11.0 •

Changelog

Source

1.11.0 (2021-05-11)

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

<a name="1.10.1"></a>

23
6
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc