Merge pull request #2082 from gradido/fix-move-memo-chars-size-in-const

[Refactor] Move MEMO_MIN_CHARS and MEMO_MAX_CHARS to const file
This commit is contained in:
Hannes Heine 2022-07-25 12:52:39 +02:00 committed by GitHub
commit 8f7ad0ac39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 15 deletions

View File

@ -54,11 +54,11 @@ import {
updateCreations, updateCreations,
} from './util/creations' } from './util/creations'
import { import {
CONTRIBUTIONLINK_MEMO_MAX_CHARS,
CONTRIBUTIONLINK_MEMO_MIN_CHARS,
CONTRIBUTIONLINK_NAME_MAX_CHARS, CONTRIBUTIONLINK_NAME_MAX_CHARS,
CONTRIBUTIONLINK_NAME_MIN_CHARS, CONTRIBUTIONLINK_NAME_MIN_CHARS,
FULL_CREATION_AVAILABLE, FULL_CREATION_AVAILABLE,
MEMO_MAX_CHARS,
MEMO_MIN_CHARS,
} from './const/const' } from './const/const'
// const EMAIL_OPT_IN_REGISTER = 1 // const EMAIL_OPT_IN_REGISTER = 1
@ -595,11 +595,8 @@ export class AdminResolver {
logger.error(`The memo must be initialized!`) logger.error(`The memo must be initialized!`)
throw new Error(`The memo must be initialized!`) throw new Error(`The memo must be initialized!`)
} }
if ( if (memo.length < MEMO_MIN_CHARS || memo.length > MEMO_MAX_CHARS) {
memo.length < CONTRIBUTIONLINK_MEMO_MIN_CHARS || const msg = `The value of 'memo' with a length of ${memo.length} did not fulfill the requested bounderies min=${MEMO_MIN_CHARS} and max=${MEMO_MAX_CHARS}`
memo.length > CONTRIBUTIONLINK_MEMO_MAX_CHARS
) {
const msg = `The value of 'memo' with a length of ${memo.length} did not fulfill the requested bounderies min=${CONTRIBUTIONLINK_MEMO_MIN_CHARS} and max=${CONTRIBUTIONLINK_MEMO_MAX_CHARS}`
logger.error(`${msg}`) logger.error(`${msg}`)
throw new Error(`${msg}`) throw new Error(`${msg}`)
} }

View File

@ -11,9 +11,7 @@ import { Contribution, ContributionListResult } from '@model/Contribution'
import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
import { User } from '@model/User' import { User } from '@model/User'
import { validateContribution, getUserCreation, updateCreations } from './util/creations' import { validateContribution, getUserCreation, updateCreations } from './util/creations'
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
const MEMO_MAX_CHARS = 255
const MEMO_MIN_CHARS = 5
@Resolver() @Resolver()
export class ContributionResolver { export class ContributionResolver {

View File

@ -34,9 +34,7 @@ import { virtualLinkTransaction, virtualDecayTransaction } from '@/util/virtualT
import Decimal from 'decimal.js-light' import Decimal from 'decimal.js-light'
import { BalanceResolver } from './BalanceResolver' import { BalanceResolver } from './BalanceResolver'
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
const MEMO_MAX_CHARS = 255
const MEMO_MIN_CHARS = 5
export const executeTransaction = async ( export const executeTransaction = async (
amount: Decimal, amount: Decimal,

View File

@ -8,5 +8,5 @@ export const FULL_CREATION_AVAILABLE = [
] ]
export const CONTRIBUTIONLINK_NAME_MAX_CHARS = 100 export const CONTRIBUTIONLINK_NAME_MAX_CHARS = 100
export const CONTRIBUTIONLINK_NAME_MIN_CHARS = 5 export const CONTRIBUTIONLINK_NAME_MIN_CHARS = 5
export const CONTRIBUTIONLINK_MEMO_MAX_CHARS = 255 export const MEMO_MAX_CHARS = 255
export const CONTRIBUTIONLINK_MEMO_MIN_CHARS = 5 export const MEMO_MIN_CHARS = 5