New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-formdata-validator

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-formdata-validator - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

1

dist/base-rules.d.ts

@@ -13,2 +13,3 @@ export declare const baseValidatorRule: {

ipv4(value: any): string | undefined;
ipV6(value: any): string | undefined;
};

60

dist/js-formdata-validator.js
var m = Object.defineProperty;
var f = (t, r, e) => r in t ? m(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
var o = (t, r, e) => (f(t, typeof r != "symbol" ? r + "" : r, e), e);
const n = {
const l = {
required: "The field cannot be empty",

@@ -15,31 +15,32 @@ array: "The field must be instance of Array",

max: "The field has maximum of {maxSize} but it got value {value}",
ipv4: "The field must be an IPv4 address"
ipv4: "The field must be an IPv4 address",
ipV6: "The field must be an IPv6 address"
}, u = {
required(t) {
if (t === void 0 || t === "" || t === null)
return n.required;
return l.required;
},
array(t) {
if (!(t instanceof Array))
return n.array;
return l.array;
},
integer(t) {
if (!Number.isInteger(t))
return n.integer;
return l.integer;
},
numeric(t) {
if (typeof t != "number")
return n.numeric;
return l.numeric;
},
string(t) {
if (typeof t != "string")
return n.string;
return l.string;
},
boolean(t) {
if (typeof t != "boolean")
return n.boolean;
return l.boolean;
},
allowed(t, ...r) {
if (!r.includes(t))
return n.allowed.replace(
return l.allowed.replace(
"{args}",

@@ -51,3 +52,3 @@ r.join(", ")

if (!/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(t))
return n.email;
return l.email;
},

@@ -58,7 +59,7 @@ min(t, r) {

if (e < r)
return n.min.replace("{minSize}", r.toString()).replace("{value}", e.toString());
return l.min.replace("{minSize}", r.toString()).replace("{value}", e.toString());
} else if (typeof t == "string") {
const e = t.length;
if (e < r)
return n.min.replace("{minSize}", r.toString()).replace("{value}", e.toString());
return l.min.replace("{minSize}", r.toString()).replace("{value}", e.toString());
}

@@ -70,7 +71,7 @@ },

if (e > r)
return n.max.replace("{maxSize}", r.toString()).replace("{value}", e.toString());
return l.max.replace("{maxSize}", r.toString()).replace("{value}", e.toString());
} else if (typeof t == "string") {
const e = t.length;
if (e > r)
return n.max.replace("{maxSize}", r.toString()).replace("{value}", e.toString());
return l.max.replace("{maxSize}", r.toString()).replace("{value}", e.toString());
}

@@ -81,3 +82,8 @@ },

if (!new RegExp(`^${r}$`).test(t.toString()))
return n.ipv4;
return l.ipv4;
},
ipV6(t) {
const r = "((([0-9a-fA-F]){1,4}):){7}([0-9a-fA-F]){1,4}";
if (!new RegExp(`^${r}$`).test(t.toString()))
return l.ipV6;
}

@@ -116,3 +122,3 @@ };

class p {
constructor({ formData: r, customRules: e, rules: a, stopOnFirstFailure: i }) {
constructor({ formData: r, customRules: e, rules: a, stopOnFirstFailure: i } = {}) {
o(this, "formData");

@@ -151,6 +157,6 @@ o(this, "rules");

async validateArrayObjects(r, e, a) {
const i = e.indexOf("*"), l = this.formData[e[i - 1]];
for (let s = 0; s < l.length; s++)
const i = e.indexOf("*"), n = this.formData[e[i - 1]];
for (let s = 0; s < n.length; s++)
if (!a.every((d) => {
typeof this.getValidatorResult(r, l[s], d) > "u";
typeof this.getValidatorResult(r, n[s], d) > "u";
})) {

@@ -166,7 +172,7 @@ const d = r.replace("*", `${s}`);

let i = this.formData;
for (const l of e)
i = i[l];
for (const n of e)
i = i[n];
if (this.stopOnFirstFailure)
for (const l of a) {
const s = await this.getValidatorResult(r, i, l);
for (const n of a) {
const s = await this.getValidatorResult(r, i, n);
if (s) {

@@ -204,7 +210,7 @@ this.validatorError.add(r, s);

return;
const l = r.split(".").reduce((s, h) => s[h], this.formData);
return this.validator[a](l, ...i);
const n = r.split(".").reduce((s, h) => s[h], this.formData);
return this.validator[a](n, ...i);
}
parseRule(r) {
const [e, a] = r.split(":"), i = a ? a.split(",").map((l) => l.trim()) : [];
const [e, a] = r.split(":"), i = a ? a.split(",").map((n) => n.trim()) : [];
return [e, i];

@@ -327,3 +333,3 @@ }

parseRule(r) {
const [e, a] = r.split(":"), i = a ? a.split(",").map((l) => l.trim()) : [];
const [e, a] = r.split(":"), i = a ? a.split(",").map((n) => n.trim()) : [];
return [e, i];

@@ -330,0 +336,0 @@ }

@@ -14,3 +14,3 @@ import type { FormData, FormState, ValidationRules, BaseValidatorRule, CustomRules } from "./type";

*/
constructor({ formData, customRules, rules, stopOnFirstFailure }: FormState);
constructor({ formData, customRules, rules, stopOnFirstFailure }?: FormState);
/**

@@ -17,0 +17,0 @@ * Merges the base rules and custom rules into a single object.

{
"name": "js-formdata-validator",
"private": false,
"version": "0.1.0",
"version": "0.1.1",
"type": "module",

@@ -6,0 +6,0 @@ "main": "./dist/js-formdata-validator.umd.cjs",

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