Skip to content

Commit

Permalink
feat: updated readme & docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rezakhademix committed Jun 13, 2024
1 parent 6c6d08d commit 6568d11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.0.7 (2024-06-13)

- History of changes: see https://github.com/rezakhademix/govalidator/compare/v2.0.6...v2.0.7

## v2.0.6 (2024-05-30)

- History of changes: see https://github.com/rezakhademix/govalidator/compare/v2.0.5...v2.0.6
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ Each validation rule in GoValidator has it's own default message, e.g: `required
| DefaultInt | `DefaultInt` sets a default value for any pointer to an int that is passed. |
| DefaultFloat | `DefaultFloat` sets a default value for any pointer to a float that is passed. |
| DefaultString | `DefaultString` sets a default value for any pointer to a string that is passed. |
| IsJSON | `IsJSON` will check if given string is a valid JSON. |
| CustomRule | `CustomRule` is a dynamic method to define any custom validation rule. |

### Functions (other common validation rules)
---
| Method | Description |
| ------ | ------------------------------------------------------------------- |
|--------|---------------------------------------------------------------------|
| In | `In` checks given value is included in the provided list of values. |
| Unique | `Unique` checks whether values in the provided slice are unique. |

Expand Down Expand Up @@ -125,7 +126,7 @@ Each validation rule in GoValidator has it's own default message, e.g: `required
var profile Profile
// after filling profile struct data with binding or other methods
// after filling profile struct with binding or other methods
v := govalidator.New()
Expand Down Expand Up @@ -155,12 +156,13 @@ Each validation rule in GoValidator has it's own default message, e.g: `required
Name string `json:"name"`
Description string `json:"description"`
Status int `json:"status"`
Meta string `json:"meta"`
}
var categoryCreateReq CategoryCreateReq
// after filling categoryCreateReq struct data with binding or other methods
// after filling CategoryCreateReq struct with binding or other methods
v := govalidator.New() // be sure to import govalidator/v2
Expand All @@ -169,9 +171,10 @@ Each validation rule in GoValidator has it's own default message, e.g: `required
MaxString(req.Name, nameMaxLength, "name", msgCategoryNameMaxLength).
MinString(req.Name, nameMinLength, "name", msgCategoryNameMinLength).
NotExists(req.Name, "categories", "name", "name", msgCategoryNameAlreadyExists). // ensure the value of req.Name does not exist in the "name" column of the "categories" table in the database
MaxString(req.Description, descriptionMaxLength, "description", msgdescriptionMaxLength).
MaxString(req.Description, descriptionMaxLength, "description", msgDescriptionMaxLength).
MinInt(req.Status, minStatus, "status", msgMinCategoryStatusIsWrong).
MaxInt(req.Status, maxStatus, "status", msgMaxCategoryStatusIsWrong).
IsJSON(req.Meta, "meta", msgMetaMustBeJSON).
When(req.ParentID != nil, func() {
v.Exists(*req.ParentID, "categories", "id", "parent_id", msgCategoryParentIDNotExist) // checks if the value of req.ParentID exists in the "id" column of the "categories" table in the database
}).
Expand Down

0 comments on commit 6568d11

Please sign in to comment.