Max answer length 240 chars

This commit is contained in:
James Grugett 2022-04-16 18:00:40 -05:00
parent 22dd206f12
commit f88dc56e4b
3 changed files with 6 additions and 3 deletions

View File

@ -29,3 +29,5 @@ export const getNoneAnswer = (contractId: string, creator: User) => {
text: 'None',
}
}
export const MAX_ANSWER_LENGTH = 240

View File

@ -9,7 +9,7 @@ import {
} from '../../common/contract'
import { User } from '../../common/user'
import { getLoanAmount, getNewMultiBetInfo } from '../../common/new-bet'
import { Answer } from '../../common/answer'
import { Answer, MAX_ANSWER_LENGTH } from '../../common/answer'
import { getContract, getValues } from './utils'
import { sendNewAnswerEmail } from './emails'
import { Bet } from '../../common/bet'
@ -31,7 +31,7 @@ export const createAnswer = functions.runWith({ minInstances: 1 }).https.onCall(
if (amount <= 0 || isNaN(amount) || !isFinite(amount))
return { status: 'error', message: 'Invalid amount' }
if (!text || typeof text !== 'string' || text.length > 10000)
if (!text || typeof text !== 'string' || text.length > MAX_ANSWER_LENGTH)
return { status: 'error', message: 'Invalid text' }
// Run as transaction to prevent race conditions.

View File

@ -22,6 +22,7 @@ import {
} from '../../../common/calculate-dpm'
import { firebaseLogin } from '../../lib/firebase/users'
import { Bet } from '../../../common/bet'
import { MAX_ANSWER_LENGTH } from '../../../common/answer'
export function CreateAnswerPanel(props: {
contract: FullContract<DPM, FreeResponse>
@ -84,7 +85,7 @@ export function CreateAnswerPanel(props: {
className="textarea textarea-bordered w-full resize-none"
placeholder="Type your answer..."
rows={1}
maxLength={10000}
maxLength={MAX_ANSWER_LENGTH}
/>
<div />
<Col