@@ -116,14 +116,12 @@ export function InsertAlterRowForm(props: {
116
116
const form = createForm < FormRow > ( ( ) => ( {
117
117
defaultValues : props . row ?? buildDefault ( props . schema ) ,
118
118
onSubmit : async ( { value } ) => {
119
- console . debug ( " Submitting:" , value ) ;
119
+ console . debug ( ` Submitting {original ? "update" : "insert"}:` , value ) ;
120
120
try {
121
121
if ( original ) {
122
- const response = await updateRow ( props . schema , value ) ;
123
- console . debug ( "UpdateRowResponse:" , response ) ;
122
+ await updateRow ( props . schema , value ) ;
124
123
} else {
125
- const response = await insertRow ( props . schema . name , value ) ;
126
- console . debug ( "InsertRowResponse:" , response ) ;
124
+ await insertRow ( props . schema . name , value ) ;
127
125
}
128
126
129
127
props . rowsRefetch ( ) ;
@@ -170,11 +168,21 @@ export function InsertAlterRowForm(props: {
170
168
name = { col . name }
171
169
validators = { {
172
170
onChange : ( { value } : { value : string | undefined } ) => {
171
+ if ( value !== undefined ) {
172
+ // TODO: Better input validation
173
+ if ( value === "" && col . data_type !== "Text" ) {
174
+ return `Invalid value for: ${ col . data_type } ` ;
175
+ }
176
+ return undefined ;
177
+ }
178
+
173
179
const defaultValue = getDefaultValue ( col . options ) ;
174
180
if ( defaultValue !== undefined ) {
175
181
return undefined ;
176
182
}
177
- return value !== undefined ? undefined : "Missing value" ;
183
+ if ( isNotNull ( col . options ) ) {
184
+ return `Missing value for ${ col . name } ` ;
185
+ }
178
186
} ,
179
187
} }
180
188
children = { formFieldBuilder (
0 commit comments