@@ -400,6 +400,10 @@ export default class ConfigValidator implements IConfigValidator {
400400
401401 col . showIn = this . validateAndNormalizeShowIn ( resInput , inCol , errors , warnings ) ;
402402
403+ if ( col . showIn . create && inCol . fillOnCreate !== undefined ) {
404+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " is present on crate page and has fillOnCreate` ) ;
405+ }
406+
403407 // check col.required is boolean or object
404408 if ( inCol . required && ! ( ( typeof inCol . required === 'boolean' ) || ( typeof inCol . required === 'object' ) ) ) {
405409 errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " required must be a boolean or object` ) ;
@@ -459,6 +463,47 @@ export default class ConfigValidator implements IConfigValidator {
459463 }
460464 }
461465 }
466+
467+ // check suggestOnCreate types
468+ if ( inCol . suggestOnCreate !== undefined ) {
469+ if ( ! col . showIn . create ) {
470+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " suggestOnCreate is present, while column is hidden on create page` ) ;
471+ }
472+
473+ if ( inCol . suggestOnCreate === '' || inCol . suggestOnCreate === null ) {
474+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " suggestOnCreate must not be empty` ) ;
475+ }
476+
477+ if ( ! [ 'string' , 'number' , 'boolean' , 'object' ] . includes ( typeof inCol . suggestOnCreate ) ) {
478+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " suggestOnCreate must be a string, number, boolean or object` ) ;
479+ }
480+
481+ // if suggestOnCreate is string, column should be one of the types with text inputs
482+ if ( typeof inCol . suggestOnCreate === 'string' && ! [ AdminForthDataTypes . STRING , AdminForthDataTypes . DATE , AdminForthDataTypes . DATETIME , AdminForthDataTypes . TIME , AdminForthDataTypes . TEXT , AdminForthDataTypes . RICHTEXT , undefined ] . includes ( inCol . type ) ) {
483+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " suggestOnCreate value does not match type of a column` ) ;
484+ }
485+
486+ if ( typeof inCol . suggestOnCreate === 'number' && ! [ AdminForthDataTypes . INTEGER , AdminForthDataTypes . FLOAT , AdminForthDataTypes . DECIMAL ] . includes ( inCol . type ) ) {
487+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " suggestOnCreate value does not match type of a column` ) ;
488+ }
489+
490+ if ( typeof inCol . suggestOnCreate === 'boolean' && inCol . type !== AdminForthDataTypes . BOOLEAN ) {
491+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " suggestOnCreate value does not match type of a column` ) ;
492+ }
493+
494+ if ( inCol . enum && ! inCol . enum . map ( ( ei ) => ei . value ) . includes ( inCol . suggestOnCreate ) ) {
495+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " suggestOnCreate value is not in enum` ) ;
496+ }
497+
498+ if ( typeof inCol . suggestOnCreate === 'object' && inCol . type !== AdminForthDataTypes . JSON ) {
499+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " suggestOnCreate value does not match type of a column` ) ;
500+ }
501+
502+ if ( inCol . isArray ?. enabled && ! Array . isArray ( inCol . suggestOnCreate ) ) {
503+ errors . push ( `Resource "${ res . resourceId } " column "${ col . name } " isArray is enabled but suggestOnCreate is not an array` ) ;
504+ }
505+ }
506+
462507 if ( col . foreignResource ) {
463508
464509 if ( ! col . foreignResource . resourceId ) {
0 commit comments