feat(api): prevent invalid kind values

This commit is contained in:
Jef Roosens 2022-06-17 13:56:38 +02:00
parent bb5643bb03
commit bd07964509
Signed by untrusted user: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 21 additions and 10 deletions

View file

@ -1,5 +1,7 @@
module models
pub const valid_kinds = ['git', 'url']
pub struct TargetArch {
pub:
id int [primary; sql: serial]
@ -14,7 +16,7 @@ pub fn (gra &TargetArch) str() string {
pub struct Target {
pub mut:
id int [primary; sql: serial]
id int [primary; sql: serial]
kind string [nonull]
// If kind is git: URL of the Git repository
// If kind is url: URL to PKGBUILD file
@ -35,6 +37,7 @@ pub mut:
pub fn (gr &Target) str() string {
mut parts := [
'id: $gr.id',
'kind: $gr.kind',
'url: $gr.url',
'branch: $gr.branch',
'repo: $gr.repo',