Cakehph3:我们如何验证 cakephp 中的枚举类型 Mysql 字段?
Cakehph3: How can we validate enum type Mysql field in cakephp?
在 Cakephp 3 模型中>Table 我想在 Cakephp 3 validationDefault method.I 中为枚举类型字段添加验证规则 method.I 做了模态蛋糕烘焙并获得了字段的默认验证 'status' 是 MySql 中的枚举类型。
$验证器->allowEmpty('status');
我想在这里进行枚举验证,以便 'status' 字段允许给定值。例如。 ENUM('Pass','Fail').
尝试使用 inList
https://api.cakephp.org/3.6/class-Cake.Validation.Validator.html#_inList
$validator
->scalar('status')
->inList('status', ['Pass','Fail'])
->allowEmpty('status');
在 Cakephp 3 模型中>Table 我想在 Cakephp 3 validationDefault method.I 中为枚举类型字段添加验证规则 method.I 做了模态蛋糕烘焙并获得了字段的默认验证 'status' 是 MySql 中的枚举类型。 $验证器->allowEmpty('status'); 我想在这里进行枚举验证,以便 'status' 字段允许给定值。例如。 ENUM('Pass','Fail').
尝试使用 inList https://api.cakephp.org/3.6/class-Cake.Validation.Validator.html#_inList
$validator
->scalar('status')
->inList('status', ['Pass','Fail'])
->allowEmpty('status');