Skip to content

Commit

Permalink
feat: Initial Release of Validata
Browse files Browse the repository at this point in the history
  • Loading branch information
SeyramWood committed Nov 11, 2023
0 parents commit 03d72bb
Show file tree
Hide file tree
Showing 11 changed files with 1,657 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Release Validata
on:
push:
branches:
- master
- dev

jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '^1.21.3'
- run: go version

- name: Verify dependencies
run: go mod verify

- name: Build
run: go build -v ./...

- name: Run go vet
run: go vet ./...

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Run Static Check
run: staticcheck ./...

- name: Install golint
run: go install golang.org/x/lint/golint@latest
- name: Run golint
run: golint ./...

- name: Run Tests
run: go test -race -vet=off ./...

release:
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release
uses: codfish/semantic-release-action@v2
with:
dry_run: false
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'master'
]
repository_url: https://github.com/SeyramWood/Validata.git
tag_format: 'v${version}'
extends: '@semantic-release/apm-config'
additional_packages: |
['@semantic-release/git']
plugins: |
['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/github', '@semantic-release/git']
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 SeyramWood

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

## About Validata

Validata is a robust and extensible validation library for handling data and input validation in your Go applications. It simplifies the process of validating user inputs, structs, etc., making it easier to ensure data integrity and security in your projects.

## Contributing

Thank you for considering contributing to the Validata package.

## License

The Validata package is open-sourced licensed under the [MIT license](https://opensource.org/licenses/MIT).
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/SeyramWood/validata

go 1.21.3

require (
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/lib/pq v1.10.9 // indirect
golang.org/x/net v0.17.0 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
90 changes: 90 additions & 0 deletions locale/en.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package locale

// EN locale validation message.
var EN = map[string]any{
"required": "The %s field is required.",
"string": "The %s must be a string.",
"alpha": "The %s may only contain letters.",
"numeric": "The %s must be a number.",
"alpha_numeric": "The %s may only contain letters and numbers.",
"int": "The %s must be an integer.",
"uint": "The %s must be a positive integer.",
"float": "The %s must be a float.",
"email": "The %s must be a valid email address.",
"phone": "The %s must be a valid phone number.",
"phone_with_code": "The %s must be a valid phone number with country code.",
"username": "The %s must be a valid email address or phone number or phone number with country code.",
"match": "The %s does not matched.",
"same": "The %s and %s must match.",
"unique": "The %s has already been taken.",
"bool": "The %s field must be true.",
"file": "The %s must be a file.",
"file_type": "The %s must be a file of type: %s.",
"image": "The %s must be an image.",
"image_type": "The %s must be an image of type: %s.",
"mimes": "The %s must be a file of type: %s.",
"gh_card": "The %s must be a valid Ghana Card.",
"gh_gps": "The %s must be a valid Ghana digital address.",
"gt": map[string]string{
"numeric": "The %s must be greater than %s.",
"file": "The %s must be greater than %s megabytes.",
"string": "The %s must be greater than %s characters.",
"slice": "The %s must have more than %s items.",
},
"gte": map[string]string{
"numeric": "The %s must be greater than or equal to %s.",
"file": "The %s must be greater than or equal to %s megabytes.",
"string": "The %s must be greater than or equal to %s characters.",
"slice": "The %s must have %s items or more.",
},
"lt": map[string]string{
"numeric": "The %s must be less than %s.",
"file": "The %s must be less than %s megabytes.",
"string": "The %s must be less than %s characters.",
"slice": "The %s must have less than %s items.",
},
"lte": map[string]string{
"numeric": "The %s must be less than or equal to %s.",
"file": "The %s must be less than or equal to %s megabytes.",
"string": "The %s must be less than or equal to %s characters.",
"slice": "The %s must not have more than %s items.",
},
"min": map[string]string{
"numeric": "The %s must be at least %s",
"file": "The %s must be at least %s megabytes.",
"string": "The %s must be at least %s characters.",
"slice": "The %s must have at least %s items.",
},
"max": map[string]string{
"numeric": "The %s must not be greater than %s.",
"file": "The %s must not be greater than %s megabytes.",
"string": "The %s must not be greater than %s characters.",
"slice": "The %s must not have more than %s items.",
},
"equal": map[string]string{
"numeric": "The %s must be equal to %s.",
"file": "The %s must be equal to %s megabytes.",
"string": "The %s must be equal to %s characters.",
"slice": "The %s must be equal to %s items.",
},
"between": map[string]string{
"numeric": "The %s must be between %s and %s.",
"file": "The %s must be between %s and %s megabytes.",
"string": "The %s must be between %s and %s characters.",
"slice": "The %s must be between %s and %s items.",
},
"from": map[string]string{
"numeric": "The %s must be from %s to %s.",
"file": "The %s must be from %s to %s megabytes.",
"string": "The %s must be from %s to %s characters.",
"slice": "The %s must be from %s to %s items.",
},
"size": map[string]string{
"numeric": "The %s must be %s.",
"file_kb": "The %s must be %s kilobytes.",
"file_mb": "The %s must be %s megabytes.",
"file_gb": "The %s must be %s gigabytes.",
"string": "The %s must be %s characters.",
"slice": "The %s must contain %s items.",
},
}
90 changes: 90 additions & 0 deletions locale/fr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package locale

// FR locale validation message.
var FR = map[string]any{
"required": "Le champ %s est requis.",
"string": "Le champ %s doit être une chaîne de caractères.",
"alpha": "Le champ %s ne peut contenir que des lettres.",
"numeric": "Le champ %s doit être un nombre.",
"alpha_numeric": "Le champ %s ne peut contenir que des lettres et des chiffres.",
"int": "Le champ %s doit être un entier.",
"uint": "Le champ %s doit être un entier positif.",
"float": "Le champ %s doit être un nombre décimal.",
"email": "Le champ %s doit être une adresse email valide.",
"phone": "Le champ %s doit être un numéro de téléphone valide.",
"phone_with_code": "Le champ %s doit être un numéro de téléphone valide avec le code du pays.",
"username": "Le champ %s doit être une adresse email valide, un numéro de téléphone valide ou un numéro de téléphone avec le code du pays.",
"match": "Le champ %s ne correspond pas.",
"same": "Les champs %s et %s doivent correspondre.",
"unique": "Le %s a déjà été pris.",
"bool": "Le champ %s doit être vrai.",
"file": "Le champ %s doit être un fichier.",
"file_type": "Le champ %s doit être un fichier de type : %s.",
"image": "Le champ %s doit être une image.",
"image_type": "Le champ %s doit être une image de type : %s.",
"mimes": "Le champ %s doit être un fichier de type : %s.",
"gh_card": "Le champ %s doit être une carte d'identité ghanéenne valide.",
"gh_gps": "Le champ %s doit être une adresse numérique ghanéenne valide.",
"gt": map[string]string{
"numeric": "Le champ %s doit être supérieur à %s.",
"file": "Le champ %s doit être supérieur à %s mégaoctets.",
"string": "Le champ %s doit comporter plus de %s caractères.",
"slice": "Le champ %s doit contenir plus de %s éléments.",
},
"gte": map[string]string{
"numeric": "Le champ %s doit être supérieur ou égal à %s.",
"file": "Le champ %s doit être supérieur ou égal à %s mégaoctets.",
"string": "Le champ %s doit comporter au moins %s caractères.",
"slice": "Le champ %s doit contenir %s éléments ou plus.",
},
"lt": map[string]string{
"numeric": "Le champ %s doit être inférieur à %s.",
"file": "Le champ %s doit être inférieur à %s mégaoctets.",
"string": "Le champ %s doit comporter moins de %s caractères.",
"slice": "Le champ %s doit contenir moins de %s éléments.",
},
"lte": map[string]string{
"numeric": "Le champ %s doit être inférieur ou égal à %s.",
"file": "Le champ %s doit être inférieur ou égal à %s mégaoctets.",
"string": "Le champ %s doit comporter %s caractères ou moins.",
"slice": "Le champ %s ne doit pas contenir plus de %s éléments.",
},
"min": map[string]string{
"numeric": "Le champ %s doit être d'au moins %s",
"file": "Le champ %s doit être d'au moins %s mégaoctets.",
"string": "Le champ %s doit comporter au moins %s caractères.",
"slice": "Le champ %s doit contenir au moins %s éléments.",
},
"max": map[string]string{
"numeric": "Le champ %s ne doit pas être supérieur à %s.",
"file": "Le champ %s ne doit pas dépasser %s mégaoctets.",
"string": "Le champ %s ne doit pas comporter plus de %s caractères.",
"slice": "Le champ %s ne doit pas contenir plus de %s éléments.",
},
"equal": map[string]string{
"numeric": "Le champ %s doit être égal à %s.",
"file": "Le champ %s doit être égal à %s mégaoctets.",
"string": "Le champ %s doit comporter exactement %s caractères.",
"slice": "Le champ %s doit comporter exactement %s éléments.",
},
"between": map[string]string{
"numeric": "Le champ %s doit être compris entre %s et %s.",
"file": "Le champ %s doit être compris entre %s et %s mégaoctets.",
"string": "Le champ %s doit comporter entre %s et %s caractères.",
"slice": "Le champ %s doit comporter entre %s et %s éléments.",
},
"from": map[string]string{
"numeric": "Le champ %s doit être compris entre %s et %s.",
"file": "Le champ %s doit être compris entre %s et %s mégaoctets.",
"string": "Le champ %s doit comporter entre %s et %s caractères.",
"slice": "Le champ %s doit comporter entre %s et %s éléments.",
},
"size": map[string]string{
"numeric": "Le champ %s doit avoir une taille de %s.",
"file_kb": "Le champ %s doit avoir une taille de %s kilooctets.",
"file_mb": "Le champ %s doit avoir une taille de %s mégaoctets.",
"file_gb": "Le champ %s doit avoir une taille de %s gigaoctets.",
"string": "Le champ %s doit comporter %s caractères.",
"slice": "Le champ %s doit contenir %s éléments.",
},
}
Loading

0 comments on commit 03d72bb

Please sign in to comment.