@@ -17,7 +17,6 @@ import {
1717 inheritableInLegacyEnvironments ,
1818 isBoolean ,
1919 isMutuallyExclusiveWith ,
20- isObjectWith ,
2120 isOptionalProperty ,
2221 isRequiredProperty ,
2322 isString ,
@@ -1122,8 +1121,8 @@ function normalizeAndValidateEnvironment(
11221121 topLevelEnv ,
11231122 rawEnv ,
11241123 "triggers" ,
1125- isObjectWith ( "crons" ) ,
1126- { crons : [ ] }
1124+ validateTriggers ,
1125+ { crons : undefined }
11271126 ) ,
11281127 assets : normalizeAndValidateAssets ( diagnostics , topLevelEnv , rawEnv ) ,
11291128 limits : normalizeAndValidateLimits ( diagnostics , topLevelEnv , rawEnv ) ,
@@ -1509,6 +1508,37 @@ const validateAndNormalizeRules = (
15091508 ) ;
15101509} ;
15111510
1511+ const validateTriggers : ValidatorFn = ( diagnostics , field , value : unknown ) => {
1512+ if ( value === undefined || value === null ) {
1513+ return true ;
1514+ }
1515+
1516+ if ( typeof value !== "object" ) {
1517+ diagnostics . errors . push (
1518+ `Expected "${ field } " to be of type object but got ${ JSON . stringify (
1519+ value
1520+ ) } .`
1521+ ) ;
1522+ return false ;
1523+ }
1524+
1525+ let isValid = true ;
1526+
1527+ if ( "crons" in value && ! Array . isArray ( value . crons ) ) {
1528+ diagnostics . errors . push (
1529+ `Expected "${ field } .crons" to be of type array, but got ${ JSON . stringify ( value ) } .`
1530+ ) ;
1531+ isValid = false ;
1532+ }
1533+
1534+ isValid =
1535+ validateAdditionalProperties ( diagnostics , field , Object . keys ( value ) , [
1536+ "crons" ,
1537+ ] ) && isValid ;
1538+
1539+ return isValid ;
1540+ } ;
1541+
15121542const validateRules =
15131543 ( envName : string ) : ValidatorFn =>
15141544 ( diagnostics , field , envValue , config ) => {
0 commit comments