| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace {{namespace_start}}validate{{namespace_end}};
- use think\Validate;
- /**
- * {{menu_name}}验证器
- */
- class {{class_name}}Validate extends Validate
- {
- /**
- * 定义验证规则
- */
- protected $rule = [
- {% for column in columns %}
- {% if column.is_required == 2 and column.is_pk != 2 %}
- '{{column.column_name}}' => 'require',
- {% endif %}
- {% endfor %}
- ];
- /**
- * 定义错误信息
- */
- protected $message = [
- {% for column in columns %}
- {% if column.is_required == 2 and column.is_pk != 2 %}
- '{{column.column_name}}' => '{{column.column_comment}}必须填写',
- {% endif %}
- {% endfor %}
- ];
- /**
- * 定义场景
- */
- protected $scene = [
- 'save' => [
- {% for column in columns %}
- {% if column.is_required == 2 and column.is_pk != 2 %}
- '{{column.column_name}}',
- {% endif %}
- {% endfor %}
- ],
- 'update' => [
- {% for column in columns %}
- {% if column.is_required == 2 and column.is_pk != 2 %}
- '{{column.column_name}}',
- {% endif %}
- {% endfor %}
- ],
- ];
- }
|