Verified Commit dee8d883 authored by Dave Long's avatar Dave Long
Browse files

Issue #3480180 by alexpott: Recipe validation error in 10.4.x

parent dc4a5f9e
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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: [
@@ -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.
@@ -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'),
                  ]),
                ]),
              ]),
@@ -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'),
+12 −17
Original line number Diff line number Diff line
@@ -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' => [
@@ -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' => [
@@ -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' => [
@@ -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' => [
@@ -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' => [