-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,559 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/http" | ||
"github.com/goravel/framework/contracts/validation" | ||
) | ||
|
||
type Archive struct { | ||
Paths []string `form:"paths" json:"paths"` | ||
File string `form:"file" json:"file"` | ||
} | ||
|
||
func (r *Archive) Authorize(ctx http.Context) error { | ||
return nil | ||
} | ||
|
||
func (r *Archive) Rules(ctx http.Context) map[string]string { | ||
return map[string]string{ | ||
"paths": "array", | ||
"paths.*": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_exists", | ||
"file": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_not_exists", | ||
} | ||
} | ||
|
||
func (r *Archive) Messages(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Archive) Attributes(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Archive) PrepareForValidation(ctx http.Context, data validation.Data) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/http" | ||
"github.com/goravel/framework/contracts/validation" | ||
) | ||
|
||
type Copy struct { | ||
Old string `form:"old" json:"old"` | ||
New string `form:"new" json:"new"` | ||
} | ||
|
||
func (r *Copy) Authorize(ctx http.Context) error { | ||
return nil | ||
} | ||
|
||
func (r *Copy) Rules(ctx http.Context) map[string]string { | ||
return map[string]string{ | ||
"old": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_exists", | ||
"new": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$", | ||
} | ||
} | ||
|
||
func (r *Copy) Messages(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Copy) Attributes(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Copy) PrepareForValidation(ctx http.Context, data validation.Data) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/http" | ||
"github.com/goravel/framework/contracts/validation" | ||
) | ||
|
||
type Exist struct { | ||
Path string `form:"path" json:"path"` | ||
} | ||
|
||
func (r *Exist) Authorize(ctx http.Context) error { | ||
return nil | ||
} | ||
|
||
func (r *Exist) Rules(ctx http.Context) map[string]string { | ||
return map[string]string{ | ||
"path": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_exists", | ||
} | ||
} | ||
|
||
func (r *Exist) Messages(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Exist) Attributes(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Exist) PrepareForValidation(ctx http.Context, data validation.Data) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/http" | ||
"github.com/goravel/framework/contracts/validation" | ||
) | ||
|
||
type Move struct { | ||
Old string `form:"old" json:"old"` | ||
New string `form:"new" json:"new"` | ||
} | ||
|
||
func (r *Move) Authorize(ctx http.Context) error { | ||
return nil | ||
} | ||
|
||
func (r *Move) Rules(ctx http.Context) map[string]string { | ||
return map[string]string{ | ||
"old": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_exists", | ||
"new": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_not_exists", | ||
} | ||
} | ||
|
||
func (r *Move) Messages(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Move) Attributes(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Move) PrepareForValidation(ctx http.Context, data validation.Data) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/http" | ||
"github.com/goravel/framework/contracts/validation" | ||
) | ||
|
||
type NotExist struct { | ||
Path string `form:"path" json:"path"` | ||
} | ||
|
||
func (r *NotExist) Authorize(ctx http.Context) error { | ||
return nil | ||
} | ||
|
||
func (r *NotExist) Rules(ctx http.Context) map[string]string { | ||
return map[string]string{ | ||
"path": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_not_exists", | ||
} | ||
} | ||
|
||
func (r *NotExist) Messages(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *NotExist) Attributes(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *NotExist) PrepareForValidation(ctx http.Context, data validation.Data) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/http" | ||
"github.com/goravel/framework/contracts/validation" | ||
) | ||
|
||
type Permission struct { | ||
Path string `form:"path" json:"path"` | ||
Mode uint `form:"mode" json:"mode" filter:"uint"` | ||
Owner string `form:"owner" json:"owner"` | ||
Group string `form:"group" json:"group"` | ||
} | ||
|
||
func (r *Permission) Authorize(ctx http.Context) error { | ||
return nil | ||
} | ||
|
||
func (r *Permission) Rules(ctx http.Context) map[string]string { | ||
return map[string]string{ | ||
"path": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_exists", | ||
"mode": "regex:^[0-7]{3}$|uint", | ||
"owner": "regex:^[a-zA-Z0-9_-]+$", | ||
"group": "regex:^[a-zA-Z0-9_-]+$", | ||
} | ||
} | ||
|
||
func (r *Permission) Messages(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Permission) Attributes(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Permission) PrepareForValidation(ctx http.Context, data validation.Data) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/http" | ||
"github.com/goravel/framework/contracts/validation" | ||
) | ||
|
||
type Search struct { | ||
Path string `form:"path" json:"path"` | ||
KeyWord string `form:"keyword" json:"keyword"` | ||
} | ||
|
||
func (r *Search) Authorize(ctx http.Context) error { | ||
return nil | ||
} | ||
|
||
func (r *Search) Rules(ctx http.Context) map[string]string { | ||
return map[string]string{ | ||
"path": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_exists", | ||
"keyword": "required|string", | ||
} | ||
} | ||
|
||
func (r *Search) Messages(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Search) Attributes(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *Search) PrepareForValidation(ctx http.Context, data validation.Data) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package requests | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/http" | ||
"github.com/goravel/framework/contracts/validation" | ||
) | ||
|
||
type UnArchive struct { | ||
File string `form:"file" json:"file"` | ||
Path string `form:"path" json:"path"` | ||
} | ||
|
||
func (r *UnArchive) Authorize(ctx http.Context) error { | ||
return nil | ||
} | ||
|
||
func (r *UnArchive) Rules(ctx http.Context) map[string]string { | ||
return map[string]string{ | ||
"file": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_exists", | ||
"path": "regex:^/[a-zA-Z0-9_-]+(\\/[a-zA-Z0-9_-]+)*$|path_not_exists", | ||
} | ||
} | ||
|
||
func (r *UnArchive) Messages(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *UnArchive) Attributes(ctx http.Context) map[string]string { | ||
return map[string]string{} | ||
} | ||
|
||
func (r *UnArchive) PrepareForValidation(ctx http.Context, data validation.Data) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package rules | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/validation" | ||
"github.com/spf13/cast" | ||
"panel/pkg/tools" | ||
) | ||
|
||
type PathExists struct { | ||
} | ||
|
||
// Signature The name of the rule. | ||
func (receiver *PathExists) Signature() string { | ||
return "path_exists" | ||
} | ||
|
||
// Passes Determine if the validation rule passes. | ||
func (receiver *PathExists) Passes(_ validation.Data, val any, options ...any) bool { | ||
// 用户请求过来的数据 | ||
requestValue, err := cast.ToStringE(val) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
// 判断是否为空 | ||
if len(requestValue) == 0 { | ||
return false | ||
} | ||
|
||
return tools.Exists(requestValue) | ||
} | ||
|
||
// Message Get the validation error message. | ||
func (receiver *PathExists) Message() string { | ||
return "路径 %v 不存在" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package rules | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/validation" | ||
"github.com/spf13/cast" | ||
"panel/pkg/tools" | ||
) | ||
|
||
type PathNotExists struct { | ||
} | ||
|
||
// Signature The name of the rule. | ||
func (receiver *PathNotExists) Signature() string { | ||
return "path_exists" | ||
} | ||
|
||
// Passes Determine if the validation rule passes. | ||
func (receiver *PathNotExists) Passes(_ validation.Data, val any, options ...any) bool { | ||
// 用户请求过来的数据 | ||
requestValue, err := cast.ToStringE(val) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
// 判断是否为空 | ||
if len(requestValue) == 0 { | ||
return false | ||
} | ||
|
||
return !tools.Exists(requestValue) | ||
} | ||
|
||
// Message Get the validation error message. | ||
func (receiver *PathNotExists) Message() string { | ||
return "路径 %v 已存在" | ||
} |
Oops, something went wrong.