@@ -51,6 +51,7 @@ interface CharacterFormState {
5151 displayNameError ?: string ;
5252 renpyTagError ?: string ;
5353 colorError ?: string ;
54+ notesError ?: string ;
5455}
5556
5657type FormAction =
@@ -63,6 +64,7 @@ type FormAction =
6364 | { type : "SET_NAME_ERROR" ; value : string }
6465 | { type : "SET_DISPLAY_NAME_ERROR" ; value : string }
6566 | { type : "SET_RENPY_TAG_ERROR" ; value : string }
67+ | { type : "SET_NOTES_ERROR" ; value : string }
6668 | { type : "SET_COLOR_ERROR" ; value : string } ;
6769
6870const INITIAL_EMPTY : CharacterFormState = {
@@ -83,6 +85,7 @@ const INITIAL_EMPTY: CharacterFormState = {
8385 displayNameError : "" ,
8486 renpyTagError : "" ,
8587 colorError : "" ,
88+ notesError : "" ,
8689} ;
8790
8891function formReducer (
@@ -134,6 +137,8 @@ function formReducer(
134137 return { ...state , renpyTagError : action . value } ;
135138 case "SET_COLOR_ERROR" :
136139 return { ...state , colorError : action . value } ;
140+ case "SET_NOTES_ERROR" :
141+ return { ...state , notesError : action . value } ;
137142 }
138143}
139144
@@ -158,6 +163,9 @@ function validateForm(state: CharacterFormState): {
158163 if ( ! / ^ # [ 0 - 9 A - F a - f ] { 6 } $ / . test ( state . color ) ) {
159164 errors . color = "Color must be valid hex (#RRGGBB)" ;
160165 }
166+ if ( state . notes . length > 10000 ) {
167+ errors . notes = "Notes must be 10000 characters or fewer" ;
168+ }
161169
162170 return { valid : Object . keys ( errors ) . length === 0 , errors } ;
163171}
@@ -245,6 +253,7 @@ export function CharacterEditDialog({
245253 dispatch ( { type : "SET_DISPLAY_NAME_ERROR" , value : "" } ) ;
246254 dispatch ( { type : "SET_RENPY_TAG_ERROR" , value : "" } ) ;
247255 dispatch ( { type : "SET_COLOR_ERROR" , value : "" } ) ;
256+ dispatch ( { type : "SET_NOTES_ERROR" , value : "" } ) ;
248257 } ;
249258
250259 const handleAvatarSelect = ( e : React . ChangeEvent < HTMLInputElement > ) => {
@@ -295,6 +304,8 @@ export function CharacterEditDialog({
295304 dispatch ( { type : "SET_RENPY_TAG_ERROR" , value : errors . renpyTag } ) ;
296305 if ( errors . color )
297306 dispatch ( { type : "SET_COLOR_ERROR" , value : errors . color } ) ;
307+ if ( errors . notes )
308+ dispatch ( { type : "SET_NOTES_ERROR" , value : errors . notes } ) ;
298309 return ;
299310 }
300311
@@ -557,7 +568,11 @@ export function CharacterEditDialog({
557568 value = { form . notes }
558569 onChange = { ( e ) => handleFieldChange ( "notes" , e . target . value ) }
559570 disabled = { isSaving }
571+ maxLength = { 10000 }
560572 />
573+ { form . notesError && (
574+ < p className = "text-xs text-destructive" > { form . notesError } </ p >
575+ ) }
561576 </ div >
562577
563578 { /* Love Interest + Narrator */ }
0 commit comments