Loading core/lib/Drupal/Core/Recipe/Recipe.php +4 −4 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ private static function parse(string $file): array { ]), ]), 'input' => new Optional([ new Type('associative_array'), new Type('array'), new All([ new Collection( fields: [ Loading @@ -192,7 +192,7 @@ private static function parse(string $file): array { // There can be an optional set of constraints, which is an // associative array of arrays, as in config schema. 'constraints' => new Optional([ new Type('associative_array'), new Type('array'), ]), 'data_type' => [ // The data type must be known to the typed data system. Loading @@ -211,7 +211,7 @@ private static function parse(string $file): array { new Choice(['ask', 'askHidden', 'confirm', 'choice']), ], 'arguments' => new Optional([ new Type('associative_array'), new Type('array'), ]), ]), ]), Loading @@ -224,7 +224,7 @@ private static function parse(string $file): array { 'value' => new Optional(), 'config' => new Optional([ new Sequentially([ new Type('list'), new Type('array'), new Count(2), new All([ new Type('string'), Loading core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php +12 −17 Original line number Diff line number Diff line Loading @@ -351,15 +351,13 @@ public static function providerRecipeValidation(): iterable { yield 'input definitions are an indexed array' => [ <<<YAML name: Bad input definitions input: - data_type: string description: A valid enough input, but in an indexed array. default: source: value value: Here be dragons input: false YAML, [ '[input]' => ['This value should be of type associative_array.'], '[input]' => [ 'This value should be of type array.', 'This value should be of type iterable.', ], ], ]; yield 'input data type is missing' => [ Loading Loading @@ -413,14 +411,13 @@ public static function providerRecipeValidation(): iterable { foo: data_type: string description: 'Constraints need to be associative' constraints: - Type: string constraints: false default: source: value value: Here be dragons YAML, [ '[input][foo][constraints]' => ['This value should be of type associative_array.'], '[input][foo][constraints]' => ['This value should be of type array.'], ], ]; yield 'input data type is unknown' => [ Loading Loading @@ -499,13 +496,13 @@ public static function providerRecipeValidation(): iterable { description: 'Prompt arguments must be associative' prompt: method: ask arguments: [1, 2] arguments: false default: source: value value: Here be dragons YAML, [ '[input][foo][prompt][arguments]' => ['This value should be of type associative_array.'], '[input][foo][prompt][arguments]' => ['This value should be of type array.'], ], ]; yield 'input definition without default value' => [ Loading Loading @@ -552,7 +549,7 @@ public static function providerRecipeValidation(): iterable { config: 'system.site:mail' YAML, [ '[input][foo][default][config]' => ['This value should be of type list.'], '[input][foo][default][config]' => ['This value should be of type array.'], ], ]; yield 'default value from config has too few values' => [ Loading Loading @@ -583,12 +580,10 @@ public static function providerRecipeValidation(): iterable { method: ask default: source: config config: name: system.site key: mail config: false YAML, [ '[input][foo][default][config]' => ['This value should be of type list.'], '[input][foo][default][config]' => ['This value should be of type array.'], ], ]; yield 'default value from config has non-string values' => [ Loading Loading
core/lib/Drupal/Core/Recipe/Recipe.php +4 −4 Original line number Diff line number Diff line Loading @@ -180,7 +180,7 @@ private static function parse(string $file): array { ]), ]), 'input' => new Optional([ new Type('associative_array'), new Type('array'), new All([ new Collection( fields: [ Loading @@ -192,7 +192,7 @@ private static function parse(string $file): array { // There can be an optional set of constraints, which is an // associative array of arrays, as in config schema. 'constraints' => new Optional([ new Type('associative_array'), new Type('array'), ]), 'data_type' => [ // The data type must be known to the typed data system. Loading @@ -211,7 +211,7 @@ private static function parse(string $file): array { new Choice(['ask', 'askHidden', 'confirm', 'choice']), ], 'arguments' => new Optional([ new Type('associative_array'), new Type('array'), ]), ]), ]), Loading @@ -224,7 +224,7 @@ private static function parse(string $file): array { 'value' => new Optional(), 'config' => new Optional([ new Sequentially([ new Type('list'), new Type('array'), new Count(2), new All([ new Type('string'), Loading
core/tests/Drupal/KernelTests/Core/Recipe/RecipeValidationTest.php +12 −17 Original line number Diff line number Diff line Loading @@ -351,15 +351,13 @@ public static function providerRecipeValidation(): iterable { yield 'input definitions are an indexed array' => [ <<<YAML name: Bad input definitions input: - data_type: string description: A valid enough input, but in an indexed array. default: source: value value: Here be dragons input: false YAML, [ '[input]' => ['This value should be of type associative_array.'], '[input]' => [ 'This value should be of type array.', 'This value should be of type iterable.', ], ], ]; yield 'input data type is missing' => [ Loading Loading @@ -413,14 +411,13 @@ public static function providerRecipeValidation(): iterable { foo: data_type: string description: 'Constraints need to be associative' constraints: - Type: string constraints: false default: source: value value: Here be dragons YAML, [ '[input][foo][constraints]' => ['This value should be of type associative_array.'], '[input][foo][constraints]' => ['This value should be of type array.'], ], ]; yield 'input data type is unknown' => [ Loading Loading @@ -499,13 +496,13 @@ public static function providerRecipeValidation(): iterable { description: 'Prompt arguments must be associative' prompt: method: ask arguments: [1, 2] arguments: false default: source: value value: Here be dragons YAML, [ '[input][foo][prompt][arguments]' => ['This value should be of type associative_array.'], '[input][foo][prompt][arguments]' => ['This value should be of type array.'], ], ]; yield 'input definition without default value' => [ Loading Loading @@ -552,7 +549,7 @@ public static function providerRecipeValidation(): iterable { config: 'system.site:mail' YAML, [ '[input][foo][default][config]' => ['This value should be of type list.'], '[input][foo][default][config]' => ['This value should be of type array.'], ], ]; yield 'default value from config has too few values' => [ Loading Loading @@ -583,12 +580,10 @@ public static function providerRecipeValidation(): iterable { method: ask default: source: config config: name: system.site key: mail config: false YAML, [ '[input][foo][default][config]' => ['This value should be of type list.'], '[input][foo][default][config]' => ['This value should be of type array.'], ], ]; yield 'default value from config has non-string values' => [ Loading