| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Module\Farm\Validations;
- use UCore\ValidationCore;
- /**
- * 作物摘取验证类
- *
- * @property int $pickerId 摘取者ID
- * @property int $cropId 作物ID
- * @property int $pickAmount 摘取数量
- * @property string $pickSource 摘取来源
- * @property int|null $sourceId 来源ID(可选)
- */
- class CropPickValidation extends ValidationCore
- {
- public int $pickerId;
- public int $cropId;
- public int $pickAmount;
- public string $pickSource;
- public ?int $sourceId = null;
- /**
- * 获取验证规则
- *
- * @param array $rules 自定义规则
- * @return array
- */
- public function rules($rules = []): array
- {
- return [
- [
- 'pickerId,cropId,pickAmount,pickSource', 'required'
- ],
- [
- 'pickerId,cropId,pickAmount', 'integer', 'min' => 1,
- 'msg' => '{attr}必须是大于0的整数'
- ],
- [
- 'pickSource', 'string', 'max' => 50,
- 'msg' => '摘取来源必须是字符串且长度不能超过50个字符'
- ],
- [
- 'sourceId', 'integer', 'min' => 1,
- 'msg' => '来源ID必须是大于0的整数'
- ],
- ];
- }
- }
|