Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

1
6

1.4.1

Diff

Changelog

Source

1.4.1 (2020-05-13)

Changes

  • Fix custom function issue in array rule and in root-level #136, #137

<a name="1.4.0"></a>

icebob
published 1.4.0 •

Changelog

Source

1.4.0 (2020-05-08)

New custom function signature

Thanks for @erfanium, in this version there is a new signature of custom check functions. In this new function you should always return the value. It means you can change the value, thus you can also sanitize the input value.

Old custom function:

const v = new Validator({});

const schema = {
    weight: {
        type: "custom",
        minWeight: 10,
        check(value, schema) {
            return (value < schema.minWeight)
                ? [{ type: "weightMin", expected: schema.minWeight, actual: value }]
                : true;
        }
    }
};

New custom function:

const v = new Validator({
    useNewCustomCheckerFunction: true, // using new version
});

const schema = {
    name: { type: "string", min: 3, max: 255 },
    weight: {
        type: "custom",
        minWeight: 10,
        check(value, errors, schema) {
            if (value < minWeight) errors.push({ type: "weightMin", expected: schema.minWeight, actual: value });
            if (value > 100) value = 100
            return value
        }
    }
};

Please note: the old version will be removed in the version 2.0.0!

The signature is used in custom function of built-in rules.

const v = new Validator({
    useNewCustomCheckerFunction: true // using new version
});

const schema = {
    phone: { type: "string", length: 15, custom(v, errors) => {
        if (!v.startWith("+")) errors.push({ type: "phoneNumber" })
        return v.replace(/[^\d+]/g, ""); // Sanitize: remove all special chars except numbers
    } }	
};

<a name="1.3.0"></a>

icebob
published 1.3.0 •

Changelog

Source

1.3.0 (2020-04-29)

Changes

  • Add new class rule to check the instance of value #126
  • Updated typescript definitions #127 #129
  • Fix deep-extend function to detect objects better. #128
  • Add hex check to string rule #132

<a name="1.2.0"></a>

icebob
published 1.2.0 •

Changelog

Source

1.2.0 (2020-04-05)

Changes


<a name="1.1.0"></a>

icebob
published 1.1.0 •

Changelog

Source

1.1.0 (2020-03-22)

Changes


<a name="1.0.2"></a>

icebob
published 1.0.2 •

Changelog

Source

1.0.2 (2020-02-09)

Changes

  • Fix string with pattern where regular expression contains a double quote #111 by @FranzZemen

<a name="1.0.1"></a>

icebob
published 1.0.1 •

Changelog

Source

1.0.1 (2020-02-01)

Changes

  • fix missing field property in custom rules #109

<a name="1.0.0"></a>

icebob
published 1.0.0 •

Changelog

Source

1.0.0 (2019-12-18)

Changes

  • add unique validation in array rule #104

<a name="1.0.0-beta4"></a>

icebob
published 1.0.0-beta4 •

Changelog

Source

1.0.0-beta4 (2019-11-17)

Changes

  • fix optional multi rule.
  • fix array rule return value issue (again).

<a name="1.0.0-beta2"></a>

icebob
published 1.0.0-beta3 •

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