-
Notifications
You must be signed in to change notification settings - Fork 893
/
filetype.go
118 lines (99 loc) · 2.97 KB
/
filetype.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by ent, DO NOT EDIT.
package filetype
import (
"fmt"
)
const (
// Label holds the string label denoting the filetype type in the database.
Label = "file_type"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldState holds the string denoting the state field in the database.
FieldState = "state"
// EdgeFiles holds the string denoting the files edge name in mutations.
EdgeFiles = "files"
// Table holds the table name of the filetype in the database.
Table = "file_types"
// FilesTable is the table that holds the files relation/edge.
FilesTable = "files"
// FilesInverseTable is the table name for the File entity.
// It exists in this package in order to avoid circular dependency with the "file" package.
FilesInverseTable = "files"
// FilesColumn is the table column denoting the files relation/edge.
FilesColumn = "file_type_files"
)
// Columns holds all SQL columns for filetype fields.
var Columns = []string{
FieldID,
FieldName,
FieldType,
FieldState,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
// Type defines the type for the "type" enum field.
type Type string
// TypePNG is the default value of the Type enum.
const DefaultType = TypePNG
// Type values.
const (
TypePNG Type = "png"
TypeSVG Type = "svg"
TypeJPG Type = "jpg"
)
func (_type Type) String() string {
return string(_type)
}
// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
func TypeValidator(_type Type) error {
switch _type {
case TypePNG, TypeSVG, TypeJPG:
return nil
default:
return fmt.Errorf("filetype: invalid enum value for type field: %q", _type)
}
}
// State defines the type for the "state" enum field.
type State string
// StateOn is the default value of the State enum.
const DefaultState = StateOn
// State values.
const (
StateOn State = "ON"
StateOff State = "OFF"
)
func (s State) String() string {
return string(s)
}
// StateValidator is a validator for the "state" field enum values. It is called by the builders before save.
func StateValidator(s State) error {
switch s {
case StateOn, StateOff:
return nil
default:
return fmt.Errorf("filetype: invalid enum value for state field: %q", s)
}
}
// Ptr returns a new pointer to the enum value.
func (_type Type) Ptr() *Type {
return &_type
}
// Ptr returns a new pointer to the enum value.
func (s State) Ptr() *State {
return &s
}
// comment from another template.