File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
packages/connect-react/src Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -173,11 +173,6 @@ export const FormContextProvider = <T extends ConfigurableProps>({
173173 const propErrors = ( prop : ConfigurableProp , value : unknown ) : string [ ] => {
174174 const errs : string [ ] = [ ] ;
175175 if ( prop . optional || prop . hidden || prop . disabled ) return [ ]
176- if ( typeof value === "undefined" ) {
177- return [
178- "required" ,
179- ]
180- }
181176 if ( prop . type === "app" ) {
182177 const field = fields [ prop . name ]
183178 if ( field ) {
Original file line number Diff line number Diff line change @@ -50,12 +50,12 @@ export type ValidationOpts<T extends ConfigurableProp> = {
5050
5151export function arrayPropErrors ( opts : ValidationOpts < ConfigurablePropStringArray > ) : string [ ] | undefined {
5252 const _values = valuesFromOptions ( opts . value )
53- if ( typeof _values === "undefined" ) {
53+ if ( ! opts . prop . default && typeof _values === "undefined" ) {
5454 return [
5555 "required" ,
5656 ]
5757 }
58- if ( Array . isArray ( _values ) && ! _values . length ) return [
58+ if ( ! opts . prop . default && Array . isArray ( _values ) && ! _values . length ) return [
5959 "empty array" ,
6060 ]
6161}
@@ -73,7 +73,7 @@ export function integerPropErrors(opts: ValidationOpts<ConfigurablePropInteger>)
7373 } = opts
7474 const value = valueFromOption ( valueOpt )
7575
76- if ( value == null || typeof value === "undefined" ) return [
76+ if ( ! prop . default && value == null || typeof value === "undefined" ) return [
7777 "required" ,
7878 ]
7979
@@ -92,9 +92,15 @@ export function integerPropErrors(opts: ValidationOpts<ConfigurablePropInteger>)
9292
9393export function stringPropErrors ( opts : ValidationOpts < ConfigurablePropString > ) : string [ ] | undefined {
9494 const _value = valueFromOption ( opts . value )
95- if ( ! _value ) return [
96- "string must not be empty" ,
97- ]
95+
96+ if ( ! opts . prop . default ) {
97+ if ( typeof _value === "undefined" || _value == null ) return [
98+ "required" ,
99+ ]
100+ if ( ! String ( _value ) . length ) return [
101+ "string must not be empty" ,
102+ ]
103+ }
98104}
99105
100106type AppWithExtractedCustomFields = App & {
You can’t perform that action at this time.
0 commit comments