common\models\Goods::rules PHP Метод

rules() публичный Метод

public rules ( )
    public function rules()
    {
        return [[['name', 'category_id', 'store_id', 'price', 'unit', 'description'], 'required'], ['image', 'required', 'on' => 'insert'], ['image', 'image', 'extensions' => 'jpg, png', 'mimeTypes' => 'image/jpeg, image/png', 'checkExtensionByMimeType' => false, 'minSize' => 100, 'maxSize' => 204800, 'tooBig' => '{attribute}最大不能超过200KB', 'tooSmall' => '{attribute}最小不能小于0.1KB', 'notImage' => '{file} 不是图片文件'], ['photos', 'image', 'maxFiles' => 2, 'extensions' => 'jpg, png', 'mimeTypes' => 'image/jpeg, image/png', 'checkExtensionByMimeType' => false, 'minSize' => 10240, 'maxSize' => 512000, 'tooSmall' => '{attribute}的大小至少10KB。', 'tooBig' => '{attribute}的大小不能超过500KB。', 'notImage' => '{file} 不是图片文件', 'skipOnEmpty' => false, 'on' => 'updateImages'], [['category_id', 'store_id', 'is_new', 'is_hot'], 'integer'], [['category_id'], 'exist', 'targetClass' => Category::className(), 'targetAttribute' => 'id'], [['store_id'], 'exist', 'targetClass' => Store::className(), 'targetAttribute' => 'id'], [['is_new', 'is_hot', 'is_promotion'], 'default', 'value' => self::BOOL_FALSE], [['is_new', 'is_hot', 'is_promotion'], 'in', 'range' => [self::BOOL_FALSE, self::BOOL_TRUE]], [['price', 'price_original', 'cost'], 'number', 'min' => 0], [['surplus'], 'integer', 'min' => 0, 'max' => 999, 'on' => 'insert'], [['surplus'], 'default', 'value' => 0, 'on' => 'insert'], [['sales'], 'integer', 'min' => 0], [['sales', 'cost'], 'default', 'value' => 0], [['name'], 'string', 'max' => 60], [['unit'], 'string', 'max' => 10], ['description', 'string', 'max' => 255]];
    }