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

class-validator

Package Overview
Dependencies
Maintainers
1
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.3.0 to 0.3.1

16

decorators.d.ts

@@ -108,2 +108,10 @@ import { IsEmailOptions, IsFQDNOptions, IsFloatOptions, IsURLOptions, IsIntOptions, IsCurrencyOptions } from "./ValidatorOptions";

/**
* Checks if the string is a positive float.
*/
export declare function IsPositiveFloat(options?: IsFloatOptions, annotationOptions?: ValidationOptions): (object: Object, propertyName: string) => void;
/**
* Checks if the string is a negative float.
*/
export declare function IsNegativeFloat(options?: IsFloatOptions, annotationOptions?: ValidationOptions): (object: Object, propertyName: string) => void;
/**
* Checks if the string contains any full-width chars.

@@ -153,2 +161,10 @@ */

/**
* Checks if the string is a positive integer.
*/
export declare function IsPositiveInt(options?: IsIntOptions, annotationOptions?: ValidationOptions): (object: Object, propertyName: string) => void;
/**
* Checks if the string is a negative integer.
*/
export declare function IsNegativeInt(options?: IsIntOptions, annotationOptions?: ValidationOptions): (object: Object, propertyName: string) => void;
/**
* Checks if the string is valid JSON (note: uses JSON.parse).

@@ -155,0 +171,0 @@ */

@@ -368,2 +368,38 @@ "use strict";

/**
* Checks if the string is a positive float.
*/
function IsPositiveFloat(options, annotationOptions) {
return function (object, propertyName) {
MetadataStorage_1.defaultMetadataStorage.addValidationMetadata({
type: ValidationTypes_1.ValidationTypes.IS_POSITIVE_FLOAT,
object: object,
propertyName: propertyName,
value1: options,
groups: annotationOptions && annotationOptions.groups ? annotationOptions.groups : undefined,
message: annotationOptions && annotationOptions.message ? annotationOptions.message : undefined,
always: annotationOptions && annotationOptions.always ? annotationOptions.always : undefined,
each: annotationOptions && annotationOptions.each ? annotationOptions.each : undefined
});
};
}
exports.IsPositiveFloat = IsPositiveFloat;
/**
* Checks if the string is a negative float.
*/
function IsNegativeFloat(options, annotationOptions) {
return function (object, propertyName) {
MetadataStorage_1.defaultMetadataStorage.addValidationMetadata({
type: ValidationTypes_1.ValidationTypes.IS_NEGATIVE_FLOAT,
object: object,
propertyName: propertyName,
value1: options,
groups: annotationOptions && annotationOptions.groups ? annotationOptions.groups : undefined,
message: annotationOptions && annotationOptions.message ? annotationOptions.message : undefined,
always: annotationOptions && annotationOptions.always ? annotationOptions.always : undefined,
each: annotationOptions && annotationOptions.each ? annotationOptions.each : undefined
});
};
}
exports.IsNegativeFloat = IsNegativeFloat;
/**
* Checks if the string contains any full-width chars.

@@ -560,2 +596,38 @@ */

/**
* Checks if the string is a positive integer.
*/
function IsPositiveInt(options, annotationOptions) {
return function (object, propertyName) {
MetadataStorage_1.defaultMetadataStorage.addValidationMetadata({
type: ValidationTypes_1.ValidationTypes.IS_POSITIVE_INT,
object: object,
propertyName: propertyName,
value1: options,
groups: annotationOptions && annotationOptions.groups ? annotationOptions.groups : undefined,
message: annotationOptions && annotationOptions.message ? annotationOptions.message : undefined,
always: annotationOptions && annotationOptions.always ? annotationOptions.always : undefined,
each: annotationOptions && annotationOptions.each ? annotationOptions.each : undefined
});
};
}
exports.IsPositiveInt = IsPositiveInt;
/**
* Checks if the string is a negative integer.
*/
function IsNegativeInt(options, annotationOptions) {
return function (object, propertyName) {
MetadataStorage_1.defaultMetadataStorage.addValidationMetadata({
type: ValidationTypes_1.ValidationTypes.IS_NEGATIVE_INT,
object: object,
propertyName: propertyName,
value1: options,
groups: annotationOptions && annotationOptions.groups ? annotationOptions.groups : undefined,
message: annotationOptions && annotationOptions.message ? annotationOptions.message : undefined,
always: annotationOptions && annotationOptions.always ? annotationOptions.always : undefined,
each: annotationOptions && annotationOptions.each ? annotationOptions.each : undefined
});
};
}
exports.IsNegativeInt = IsNegativeInt;
/**
* Checks if the string is valid JSON (note: uses JSON.parse).

@@ -562,0 +634,0 @@ */

2

package.json
{
"name": "class-validator",
"private": false,
"version": "0.3.0",
"version": "0.3.1",
"description": "Class-based validation in Typescript using decorators",

@@ -6,0 +6,0 @@ "license": "Apache-2.0",

@@ -11,3 +11,3 @@ # class-validator

* package has changed its name from `validator.ts` to `class-validator`.
* sanitation functionality has been removed from this library. Use [class-sanitizer][1] instead.
* sanitation functionality has been removed from this library. Use [class-sanitizer][3] instead.

@@ -14,0 +14,0 @@ ## Installation

@@ -24,2 +24,4 @@ /**

IS_FLOAT = 18,
IS_POSITIVE_FLOAT = 180,
IS_NEGATIVE_FLOAT = 181,
IS_FULL_WIDTH = 19,

@@ -35,2 +37,4 @@ IS_HALF_WIDTH = 20,

IS_INT = 28,
IS_POSITIVE_INT = 283,
IS_NEGATIVE_INT = 284,
IS_JSON = 29,

@@ -37,0 +41,0 @@ IS_LENGTH = 30,

@@ -25,2 +25,4 @@ "use strict";

ValidationTypes[ValidationTypes["IS_FLOAT"] = 18] = "IS_FLOAT";
ValidationTypes[ValidationTypes["IS_POSITIVE_FLOAT"] = 180] = "IS_POSITIVE_FLOAT";
ValidationTypes[ValidationTypes["IS_NEGATIVE_FLOAT"] = 181] = "IS_NEGATIVE_FLOAT";
ValidationTypes[ValidationTypes["IS_FULL_WIDTH"] = 19] = "IS_FULL_WIDTH";

@@ -36,2 +38,4 @@ ValidationTypes[ValidationTypes["IS_HALF_WIDTH"] = 20] = "IS_HALF_WIDTH";

ValidationTypes[ValidationTypes["IS_INT"] = 28] = "IS_INT";
ValidationTypes[ValidationTypes["IS_POSITIVE_INT"] = 283] = "IS_POSITIVE_INT";
ValidationTypes[ValidationTypes["IS_NEGATIVE_INT"] = 284] = "IS_NEGATIVE_INT";
ValidationTypes[ValidationTypes["IS_JSON"] = 29] = "IS_JSON";

@@ -105,2 +109,6 @@ ValidationTypes[ValidationTypes["IS_LENGTH"] = 30] = "IS_LENGTH";

return "float";
case ValidationTypes.IS_POSITIVE_FLOAT:
return "positive_float";
case ValidationTypes.IS_NEGATIVE_FLOAT:
return "negative_float";
case ValidationTypes.IS_FULL_WIDTH:

@@ -126,2 +134,6 @@ return "full_width";

return "int";
case ValidationTypes.IS_POSITIVE_INT:
return "positive_int";
case ValidationTypes.IS_NEGATIVE_INT:
return "negative_int";
case ValidationTypes.IS_JSON:

@@ -128,0 +140,0 @@ return "json";

@@ -114,2 +114,12 @@ import { ValidationErrorInterface } from "./ValidationErrorInterface";

/**
* Checks if the string is a positive float.
*/
isPositiveFloat(val: number, options?: IsFloatOptions): boolean;
isPositiveFloat(val: string, options?: IsFloatOptions): boolean;
/**
* Checks if the string is a negative float.
*/
isNegativeFloat(val: number, options?: IsFloatOptions): boolean;
isNegativeFloat(val: string, options?: IsFloatOptions): boolean;
/**
* Checks if the string contains any full-width chars.

@@ -160,2 +170,12 @@ */

/**
* Checks if the string is a positive integer.
*/
isPositiveInt(val: number, options?: IsIntOptions): boolean;
isPositiveInt(val: string, options?: IsIntOptions): boolean;
/**
* Checks if the string is a negative integer.
*/
isNegativeInt(val: number, options?: IsIntOptions): boolean;
isNegativeInt(val: string, options?: IsIntOptions): boolean;
/**
* Checks if the string is valid JSON (note: uses JSON.parse).

@@ -162,0 +182,0 @@ */

@@ -226,2 +226,12 @@ "use strict";

};
Validator.prototype.isPositiveFloat = function (val, options) {
var numberString = String(val);
var num = typeof val === "number" ? val : parseFloat(val);
return validatatorJs.isFloat(numberString, options) && num > 0;
};
Validator.prototype.isNegativeFloat = function (val, options) {
var numberString = String(val);
var num = typeof val === "number" ? val : parseFloat(val);
return validatatorJs.isFloat(numberString, options) && num < 0;
};
/**

@@ -291,2 +301,12 @@ * Checks if the string contains any full-width chars.

};
Validator.prototype.isPositiveInt = function (val, options) {
var numberString = String(val);
var num = typeof val === "number" ? val : parseInt(val);
return validatatorJs.isInt(numberString, options) && num > 0;
};
Validator.prototype.isNegativeInt = function (val, options) {
var numberString = String(val);
var num = typeof val === "number" ? val : parseInt(val);
return validatatorJs.isInt(numberString, options) && num < 0;
};
/**

@@ -416,2 +436,6 @@ * Checks if the string is valid JSON (note: uses JSON.parse).

return this.isFloat(value, metadata.value1);
case ValidationTypes_1.ValidationTypes.IS_POSITIVE_FLOAT:
return this.isPositiveFloat(value, metadata.value1);
case ValidationTypes_1.ValidationTypes.IS_NEGATIVE_FLOAT:
return this.isNegativeFloat(value, metadata.value1);
case ValidationTypes_1.ValidationTypes.IS_FULL_WIDTH:

@@ -439,2 +463,6 @@ return this.isFullWidth(value);

return this.isInt(value, metadata.value1);
case ValidationTypes_1.ValidationTypes.IS_POSITIVE_INT:
return this.isPositiveInt(value, metadata.value1);
case ValidationTypes_1.ValidationTypes.IS_NEGATIVE_INT:
return this.isNegativeInt(value, metadata.value1);
case ValidationTypes_1.ValidationTypes.IS_JSON:

@@ -441,0 +469,0 @@ return this.isJSON(value);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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