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

@chantouchsek/validatorjs

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chantouchsek/validatorjs - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

dist/types/lang.js

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Changelog

### [1.1.1](https://github.com/chantouchsek/validator-js/compare/v1.1.0...v1.1.1) (2022-07-06)
### Bug Fixes
* :fire: detect the prototyp polluting ([9950186](https://github.com/chantouchsek/validator-js/commit/99501868f92fb9a50869109d651b2bec54e324fc))
* :fire: incomplete string escaping or encoding ([d8cfb69](https://github.com/chantouchsek/validator-js/commit/d8cfb6926002d341e65916a051f9ebe19c76ef1b))
* correct type of step on ([3a5d87e](https://github.com/chantouchsek/validator-js/commit/3a5d87e356821a15b8da644c4162c80fec5b1915))
* inefficient regular expression ([4bdf2a1](https://github.com/chantouchsek/validator-js/commit/4bdf2a16a812119e593be5c064eac5b11ab3788c))
* using object create ([887319d](https://github.com/chantouchsek/validator-js/commit/887319dd4431331fefef38987cc07f9853de4ac3))
## [1.1.0](https://github.com/chantouchsek/validator-js/compare/v1.0.5...v1.1.0) (2022-07-06)

@@ -7,0 +18,0 @@

10

dist/lang.js

@@ -17,6 +17,7 @@ "use strict";

this._load(lang);
const messages = Object.create(this.messages);
if (message === undefined) {
message = this.messages[lang].def;
message = messages[lang].def;
}
this.messages[lang][attribute] = message;
messages[lang][attribute] = message;
}

@@ -36,7 +37,8 @@ static _load(lang) {

static _make(lang) {
const messages = Object.create(this.messages);
this._load(lang);
return new messages_1.default(lang, this.messages[lang]);
return new messages_1.default(lang, messages[lang]);
}
}
exports.default = Lang;
Lang.messages = {};
Lang.messages = Object.create({});

22

dist/main.js

@@ -12,13 +12,12 @@ "use strict";

class Validator {
constructor(input, rules, options) {
constructor(input, rules, options = {}) {
this.input = {};
this.numericRules = ['integer', 'numeric'];
this.rules = {};
const { customAttributes, customMessages, locale } = options || {};
const lang = locale || Validator.getDefaultLang();
const lang = (options === null || options === void 0 ? void 0 : options.locale) || Validator.getDefaultLang();
Validator.useLang(lang);
this.input = input || {};
this.messages = lang_1.default._make(lang);
this.messages._setCustom(customMessages || {});
this.setAttributeNames(customAttributes || {});
this.messages._setCustom(options.customMessages);
this.setAttributeNames(options.customAttributes);
this.setAttributeFormatter(Validator.attributeFormatter);

@@ -29,6 +28,5 @@ this.errors = new errors_1.default();

this.rules = this._parseRules(rules);
this.confirmedReverse = (options === null || options === void 0 ? void 0 : options.confirmedReverse) || false;
this.confirmedReverse = options.confirmedReverse;
}
check() {
const confirmedReverse = this.confirmedReverse;
for (let attribute in this.rules) {

@@ -49,3 +47,3 @@ const attributeRules = this.rules[attribute];

if (!rulePassed) {
if (name === 'confirmed' && confirmedReverse) {
if (name === 'confirmed' && this.confirmedReverse) {
attribute = `${attribute}_confirmation`;

@@ -138,3 +136,3 @@ Object.assign(rule, { attribute });

_hasRule(attribute, findRules) {
const rules = this.rules[attribute] || [];
const rules = this.rules[attribute];
for (const { name } of rules) {

@@ -206,5 +204,5 @@ if (findRules.indexOf(name) > -1) {

for (let propertyNumber = 0; propertyNumber < propertyValue.length; propertyNumber++) {
const workingValues = wildCardValues ? wildCardValues.slice() : [];
const workingValues = (wildCardValues === null || wildCardValues === void 0 ? void 0 : wildCardValues.slice()) || [];
workingValues.push(propertyNumber);
this._parseRulesCheck(attribute.replace('*', String(propertyNumber)), rulesArray, parsedRules, workingValues);
this._parseRulesCheck(attribute.replace(/\*/g, String(propertyNumber)), rulesArray, parsedRules, workingValues);
}

@@ -300,3 +298,3 @@ }

}
setAttributeNames(attributes) {
setAttributeNames(attributes = {}) {
this.messages._setAttributeNames(attributes);

@@ -303,0 +301,0 @@ }

@@ -103,3 +103,3 @@ "use strict";

}
_setCustom(customMessages) {
_setCustom(customMessages = {}) {
this.customMessages = customMessages;

@@ -106,0 +106,0 @@ }

@@ -5,3 +5,2 @@ "use strict";

const email = (value) => {
// Added umlaut support https://github.com/skaterdav85/validatorjs/issues/308
let re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/;

@@ -11,8 +10,5 @@ if (re.test(value)) {

}
// added support domain 3-n level https://github.com/skaterdav85/validatorjs/issues/384
re =
// eslint-disable-next-line no-control-regex
/^((?:[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]|[^\u0000-\u007F])+@(?:[a-zA-Z0-9]|[^\u0000-\u007F])(?:(?:[a-zA-Z0-9-]|[^\u0000-\u007F]){0,61}(?:[a-zA-Z0-9]|[^\u0000-\u007F]))?(?:\.(?:[a-zA-Z0-9]|[^\u0000-\u007F])(?:(?:[a-zA-Z0-9-]|[^\u0000-\u007F]){0,61}(?:[a-zA-Z0-9]|[^\u0000-\u007F]))?)+)*$/;
re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return re.test(value);
};
exports.email = email;
{
"name": "@chantouchsek/validatorjs",
"version": "1.1.0",
"version": "1.1.1",
"description": "The validator-js library makes data validation in JavaScript very easy in both the browser and Node.js.",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

import Massages from './messages';
import { LangTypes } from './types/lang';
export default class Lang {
static messages: Record<string, any>;
static _set(lang: string, rawMessages: Record<string, any>): void;
static _get(lang: string): Record<string, string>;
static _setRuleMessage(lang: string, attribute: string, message?: string): void;
static _load(lang: string): void;
static _make(lang: string): Massages;
static messages: Record<LangTypes, any>;
static _set(lang: LangTypes, rawMessages: Record<string, any>): void;
static _get(lang: LangTypes): Record<string, string>;
static _setRuleMessage(lang: LangTypes, attribute: string, message?: string): void;
static _load(lang: LangTypes): void;
static _make(lang: LangTypes): Massages;
}

@@ -5,2 +5,4 @@ import Messages from './messages';

import type { ValidatorOptions, VoidFunction } from './types/validator';
import { LangTypes } from './types/lang';
import { RuleType } from './types/rule';
export default class Validator {

@@ -12,17 +14,17 @@ readonly input: Record<string, any>;

hasAsync: boolean;
static lang: string;
static lang: LangTypes;
readonly numericRules: string[];
rules: Record<string, any>;
stopOnAttributes: any;
rules: Record<RuleType, any>;
stopOnAttributes: Record<string, any> | boolean | string[] | undefined;
static attributeFormatter: (attribute: string) => string;
readonly options?: ValidatorOptions;
readonly options: ValidatorOptions;
static manager: Manager;
private readonly confirmedReverse;
constructor(input?: Record<string, any> | null, rules?: Record<string, any>, options?: ValidatorOptions);
private readonly confirmedReverse?;
constructor(input?: Record<string, any> | null, rules?: Record<string, any>, options?: Partial<ValidatorOptions>);
check(): boolean;
checkAsync(passes?: boolean | (() => void), fails?: any): void;
_parseRules(rules?: Record<string, any>): Record<string, any>;
static setMessages(lang: string, messages: Record<string, any>): typeof Validator;
static getMessages(lang: string): Record<string, string>;
static useLang(lang: string): void;
_parseRules(rules?: Record<RuleType, any>): Record<string, any>;
static setMessages(lang: LangTypes, messages: Record<string, any>): typeof Validator;
static getMessages(lang: LangTypes): Record<string, string>;
static useLang(lang: LangTypes): void;
static getDefaultLang(): string;

@@ -40,3 +42,3 @@ static setAttributeFormatter(func: any): void;

_parseRulesCheck(attribute: string, rulesArray: Record<string, any>, parsedRules: Record<string, any>, wildCardValues?: any[]): void;
_parsedRulesRecurse(attribute: string, rulesArray: Record<any, string>, parsedRules: Record<string, any>, wildCardValues?: any): void;
_parsedRulesRecurse(attribute: string, rulesArray: Record<any, string>, parsedRules: Record<string, any>, wildCardValues?: number[]): void;
_parseRulesDefault(attribute: string, rulesArray: Record<string, any> | any, parsedRules: Record<string, any> | any, wildCardValues?: any): void;

@@ -48,3 +50,3 @@ _prepareRulesArray(rulesArray: Record<string, any> | any): Record<string, any>[];

_hasNumericRule(attribute: string): boolean;
setAttributeNames(attributes: Record<string, any>): void;
setAttributeNames(attributes?: Record<string, any>): void;
stopOnError(attributes: Record<string, any> | boolean): void;

@@ -51,0 +53,0 @@ static stopOnError(attributes: Record<string, any> | boolean): void;

@@ -11,3 +11,3 @@ import type { Rule } from './rule';

static _setReplacements(): void;
_setCustom(customMessages: Record<string, any>): void;
_setCustom(customMessages?: Record<string, any>): void;
_setAttributeNames(attributes: Record<string, any>): void;

@@ -14,0 +14,0 @@ _setAttributeFormatter(func: any): void;

@@ -0,3 +1,4 @@

import { LangTypes } from './lang';
export interface ValidatorOptions {
locale?: string;
locale?: LangTypes;
confirmedReverse?: boolean;

@@ -7,2 +8,2 @@ customMessages?: Record<string, any>;

}
export declare type VoidFunction = boolean | ((arg?: any) => any);
export declare type VoidFunction = boolean | ((...arg: any) => any);
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