-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
105 additions
and
20 deletions.
There are no files selected for viewing
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
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,7 @@ | ||
-- +migrate Up | ||
create type proof_operator as enum('$noop', '$eq', '$lt', '$gt', '$in', '$nin', '$ne'); | ||
alter table proofs add column operator proof_operator not null; | ||
|
||
-- +migrate Down | ||
alter table proofs drop column operator; | ||
drop type proof_operator; |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ package data | |
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,36 @@ | ||
package data | ||
|
||
type ProofOperator string | ||
|
||
const ( | ||
Noop ProofOperator = "$noop" | ||
Eq ProofOperator = "$eq" | ||
Lt ProofOperator = "$lt" | ||
Gt ProofOperator = "$gt" | ||
In ProofOperator = "$in" | ||
Nin ProofOperator = "$nin" | ||
Ne ProofOperator = "$ne" | ||
) | ||
|
||
func (o ProofOperator) String() string { | ||
return string(o) | ||
} | ||
|
||
var proofOperatorStrConv = map[string]ProofOperator{ | ||
"$noop": Noop, | ||
"$eq": Eq, | ||
"$lt": Lt, | ||
"$gt": Gt, | ||
"$in": In, | ||
"$nin": Nin, | ||
"$ne": Ne, | ||
} | ||
|
||
func ProofOperatorFromString(data string) (ProofOperator, bool) { | ||
res, ok := proofOperatorStrConv[data] | ||
return res, ok | ||
} | ||
|
||
func MustProofOperatorFromString(data string) ProofOperator { | ||
return proofOperatorStrConv[data] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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,16 @@ | ||
package handlers | ||
|
||
import ( | ||
validation "github.com/go-ozzo/ozzo-validation/v4" | ||
"github.com/rarimo/rarime-link-svc/internal/data" | ||
) | ||
|
||
var ( | ||
ErrOperator = validation.NewError("validation_is_operator", "must be a valid operator") | ||
ValidationOperator = validation.NewStringRuleWithError(isOperator, ErrOperator) | ||
) | ||
|
||
func isOperator(op string) bool { | ||
_, ok := data.ProofOperatorFromString(op) | ||
return ok | ||
} |
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
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