@formbricks/react
Advanced tools
Comparing version 0.0.8 to 0.0.9
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
var _chunkCBM6EW76js = require('../chunk-CBM6EW76.js'); | ||
require('../chunk-MBDQONOF.js'); | ||
var _chunkLJOK2OU6js = require('../chunk-LJOK2OU6.js'); | ||
require('../chunk-ARXXTIOC.js'); | ||
require('../chunk-Z2K5IH6O.js'); | ||
exports.FormbricksSchema = _chunkCBM6EW76js.FormbricksSchema; | ||
exports.FormbricksSchema = _chunkLJOK2OU6js.FormbricksSchema; |
@@ -6,3 +6,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
var _chunkMBDQONOFjs = require('../chunk-MBDQONOF.js'); | ||
var _chunkARXXTIOCjs = require('../chunk-ARXXTIOC.js'); | ||
require('../chunk-Z2K5IH6O.js'); | ||
@@ -14,2 +14,2 @@ | ||
exports.Button = _chunkMBDQONOFjs.Button; exports.Submit = _chunkMBDQONOFjs.Submit; exports.Text = _chunkMBDQONOFjs.Text; exports.Textarea = _chunkMBDQONOFjs.Textarea; | ||
exports.Button = _chunkARXXTIOCjs.Button; exports.Submit = _chunkARXXTIOCjs.Submit; exports.Text = _chunkARXXTIOCjs.Text; exports.Textarea = _chunkARXXTIOCjs.Textarea; |
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
var _chunkCBM6EW76js = require('./chunk-CBM6EW76.js'); | ||
var _chunkLJOK2OU6js = require('./chunk-LJOK2OU6.js'); | ||
@@ -9,3 +9,3 @@ | ||
var _chunkMBDQONOFjs = require('./chunk-MBDQONOF.js'); | ||
var _chunkARXXTIOCjs = require('./chunk-ARXXTIOC.js'); | ||
@@ -23,2 +23,2 @@ | ||
exports.Button = _chunkMBDQONOFjs.Button; exports.Form = _chunkZ2K5IH6Ojs.Form; exports.FormbricksSchema = _chunkCBM6EW76js.FormbricksSchema; exports.SchemaContext = _chunkZ2K5IH6Ojs.SchemaContext; exports.Submit = _chunkMBDQONOFjs.Submit; exports.Text = _chunkMBDQONOFjs.Text; exports.Textarea = _chunkMBDQONOFjs.Textarea; | ||
exports.Button = _chunkARXXTIOCjs.Button; exports.Form = _chunkZ2K5IH6Ojs.Form; exports.FormbricksSchema = _chunkLJOK2OU6js.FormbricksSchema; exports.SchemaContext = _chunkZ2K5IH6Ojs.SchemaContext; exports.Submit = _chunkARXXTIOCjs.Submit; exports.Text = _chunkARXXTIOCjs.Text; exports.Textarea = _chunkARXXTIOCjs.Textarea; |
{ | ||
"name": "@formbricks/react", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"author": "Formbricks <hola@formbricks.com>", | ||
@@ -5,0 +5,0 @@ "description": "Building React forms has never been quicker.", |
export const getValidationRules = (validation: string | undefined) => { | ||
const validationRules: string[] = []; | ||
const validationRules: any = {}; | ||
if (!validation) { | ||
@@ -7,7 +7,35 @@ return validationRules; | ||
for (const validationRule of validation.split("|")) { | ||
if (validationRule === "required" || !validationRules.includes("required")) { | ||
validationRules.push("required"); | ||
if (validationRule === "required" && !("required" in validationRules)) { | ||
validationRules.required = {}; | ||
} | ||
if (validationRule === "number" && !("number" in validationRules)) { | ||
validationRules.number = {}; | ||
} | ||
if (validationRule.startsWith("max:") && !("max" in validationRules)) { | ||
validationRules.max = { value: validationRule.split(":")[1] }; | ||
} | ||
if (validationRule.startsWith("min:") && !("min" in validationRules)) { | ||
validationRules.min = { value: validationRule.split(":")[1] }; | ||
} | ||
} | ||
return validationRules; | ||
}; | ||
export const validate = (validationRules: any) => { | ||
const validation: any = {}; | ||
if ("max" in validationRules) { | ||
validation.max = (v: string) => | ||
parseInt(v) <= validationRules.max.value || | ||
`Input must be less or equal to ${validationRules.max.value}`; | ||
} | ||
if ("min" in validationRules) { | ||
validation.min = (v: string) => | ||
parseInt(v) >= validationRules.min.value || | ||
`Input must be more or equal to ${validationRules.min.value}`; | ||
} | ||
if ("number" in validationRules) { | ||
validation.number = (v: string) => | ||
("number" in validationRules && /^[+-]?([0-9]*[.])?[0-9]+$/.test(v)) || "Input must be a number"; | ||
} | ||
return validation; | ||
}; |
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
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
60904
1279
0