api-platform / api-platform/core

HeaderParameter constraint-validators receive array value by default

Aberta
#8,499 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
PHP
Estrelas
2.6k
Forks
980
Merge médio
2d 5h
PRs com merge (30d)
48

Descrição

**API Platform version(s) affected**: 4.3.17

**Description**
The symfony constraint validators e.g. `Symfony\Component\Validator\Constraints\NotBlankValidator` receive array value by default. Because of that if we pass empty string then validation does not work. Is this a bug or a feature?

**How to reproduce**
```php
parameters: [
'foo' => new HeaderParameter(
required: true,
constraints: [new NotBlank(message: 'foo missing from header')]
),
],
```

**Possible Solution**
```php
parameters: [
'foo' => new HeaderParameter(
required: true,
constraints: [new NotBlank(message: 'foo missing from header')],
nativeType: new BuiltinType(typeIdentifier: TypeIdentifier::STRING)
),
],
```

**Additional Context**
MR to improve doc: https://github.com/api-platform/docs/pull/2322

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.