api-platform / api-platform/core

HeaderParameter constraint-validators receive array value by default

未關閉
#8,499 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
PHP
星號
2.6k
分支
980
平均合併
2 天 5 小時
30 天內合併 PR
48

描述

**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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。