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

class-validator

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

class-validator - npm Package Compare versions

Comparing version 0.8.3 to 0.8.4

2

package.json
{
"name": "class-validator",
"private": false,
"version": "0.8.3",
"version": "0.8.4",
"description": "Class-based validation with Typescript / ES6 / ES5 using decorators or validation schemas. Supports both node.js and browser",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -123,2 +123,25 @@ # class-validator

### Passing options
The `validate` function optionally expects a `ValidatorOptions` object as a second parameter.
```ts
export interface ValidatorOptions {
skipMissingProperties?: boolean;
whitelist?: boolean;
forbidNonWhitelisted?: boolean;
groups?: string[];
dismissDefaultMessages?: boolean;
validationError?: {
target?: boolean;
value?: boolean;
};
forbidUnknownValues?: boolean;
}
```
> It's highly advised to enable on `forbidUnknownValues` what prevent unknown objects to pass validation.
## Validation errors

@@ -125,0 +148,0 @@

@@ -36,2 +36,16 @@ "use strict";

var groupedMetadatas = this.metadataStorage.groupByPropertyName(targetMetadatas);
if (this.validatorOptions && this.validatorOptions.forbidUnknownValues && !targetMetadatas.length) {
var validationError = new ValidationError_1.ValidationError();
if (!this.validatorOptions ||
!this.validatorOptions.validationError ||
this.validatorOptions.validationError.target === undefined ||
this.validatorOptions.validationError.target === true)
validationError.target = object;
validationError.value = undefined;
validationError.property = undefined;
validationError.children = [];
validationError.constraints = { unknownValue: "an unknown value was passed to the validate function" };
validationErrors.push(validationError);
return;
}
if (this.validatorOptions && this.validatorOptions.whitelist)

@@ -38,0 +52,0 @@ this.whitelist(object, groupedMetadatas, validationErrors);

@@ -41,2 +41,6 @@ /**

};
/**
* Settings true will cause fail validation of unknown objects.
*/
forbidUnknownValues?: boolean;
}

Sorry, the diff of this file is not supported yet

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