Remove stringTypes

This commit is contained in:
ekzyis 2024-07-17 03:19:41 +02:00
parent 4df0b460c3
commit 08a5ce1a28
1 changed files with 7 additions and 11 deletions

View File

@ -25,19 +25,13 @@ export function generateSchema (wallet) {
let validator
const stringTypes = ['url', 'string', 'email']
if (stringTypes.includes(validationType)) {
validator = string()
if (field.validate.length) validator = validator.length(field.validate.length)
}
if (validationType === 'string') validator = string()
if (validationType === 'url') {
validator = process.env.NODE_ENV === 'development'
? validator
? string()
.or([string().matches(/^(http:\/\/)?localhost:\d+$/), string().url()], 'invalid url')
: validator
: string()
.url()
.test(async (url, context) => {
if (field.validate.torAllowed && TOR_REGEXP.test(url)) {
@ -57,8 +51,6 @@ export function generateSchema (wallet) {
})
}
if (validationType === 'email') validator = lightningAddressValidator
if (words) {
validator = array()
.transform(function (value, originalValue) {
@ -79,6 +71,8 @@ export function generateSchema (wallet) {
})
}
if (validationType === 'email') validator = lightningAddressValidator
if (validationType === 'socket') validator = string().socket()
if (validationType === 'hexOrBase64') validator = hexOrBase64Validator
@ -86,6 +80,8 @@ export function generateSchema (wallet) {
if (min !== undefined) validator = validator.min(min)
if (max !== undefined) validator = validator.max(max)
if (field.validate.length) validator = validator.length(field.validate.length)
if (!field.optional) validator = validator.required('required')
if (field.validate.test) {