@@ -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,44 @@ const validateAndNormalizeRules = (
15091508 ) ;
15101509} ;
15111510
1511+ const validateTriggers : ValidatorFn = (
1512+ diagnostics ,
1513+ triggersFieldName ,
1514+ triggersValue
1515+ ) => {
1516+ if ( triggersValue === undefined || triggersValue === null ) {
1517+ return true ;
1518+ }
1519+
1520+ if ( typeof triggersValue !== "object" ) {
1521+ diagnostics . errors . push (
1522+ `Expected "${ triggersFieldName } " to be of type object but got ${ JSON . stringify (
1523+ triggersValue
1524+ ) } .`
1525+ ) ;
1526+ return false ;
1527+ }
1528+
1529+ let isValid = true ;
1530+
1531+ if ( "crons" in triggersValue && ! Array . isArray ( triggersValue . crons ) ) {
1532+ diagnostics . errors . push (
1533+ `Expected "${ triggersFieldName } .crons" to be of type array, but got ${ JSON . stringify ( triggersValue ) } .`
1534+ ) ;
1535+ isValid = false ;
1536+ }
1537+
1538+ isValid =
1539+ validateAdditionalProperties (
1540+ diagnostics ,
1541+ triggersFieldName ,
1542+ Object . keys ( triggersValue ) ,
1543+ [ "crons" ]
1544+ ) && isValid ;
1545+
1546+ return isValid ;
1547+ } ;
1548+
15121549const validateRules =
15131550 ( envName : string ) : ValidatorFn =>
15141551 ( diagnostics , field , envValue , config ) => {
0 commit comments