MCPcopy
hub / github.com/cloudreve/cloudreve / check

Method check

ent/node_create.go:220–253  ·  view source on GitHub ↗

check runs all checks and user-defined validators on the builder.

()

Source from the content-addressed store, hash-verified

218
219// check runs all checks and user-defined validators on the builder.
220func (nc *NodeCreate) check() error {
221 if _, ok := nc.mutation.CreatedAt(); !ok {
222 return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Node.created_at"`)}
223 }
224 if _, ok := nc.mutation.UpdatedAt(); !ok {
225 return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Node.updated_at"`)}
226 }
227 if _, ok := nc.mutation.Status(); !ok {
228 return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Node.status"`)}
229 }
230 if v, ok := nc.mutation.Status(); ok {
231 if err := node.StatusValidator(v); err != nil {
232 return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Node.status": %w`, err)}
233 }
234 }
235 if _, ok := nc.mutation.Name(); !ok {
236 return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Node.name"`)}
237 }
238 if _, ok := nc.mutation.GetType(); !ok {
239 return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Node.type"`)}
240 }
241 if v, ok := nc.mutation.GetType(); ok {
242 if err := node.TypeValidator(v); err != nil {
243 return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Node.type": %w`, err)}
244 }
245 }
246 if _, ok := nc.mutation.Capabilities(); !ok {
247 return &ValidationError{Name: "capabilities", err: errors.New(`ent: missing required field "Node.capabilities"`)}
248 }
249 if _, ok := nc.mutation.Weight(); !ok {
250 return &ValidationError{Name: "weight", err: errors.New(`ent: missing required field "Node.weight"`)}
251 }
252 return nil
253}
254
255func (nc *NodeCreate) sqlSave(ctx context.Context) (*Node, error) {
256 if err := nc.check(); err != nil {

Callers 2

sqlSaveMethod · 0.95
SaveMethod · 0.45

Calls 10

StatusValidatorFunction · 0.92
TypeValidatorFunction · 0.92
WeightMethod · 0.80
CreatedAtMethod · 0.65
NewMethod · 0.65
UpdatedAtMethod · 0.65
StatusMethod · 0.65
NameMethod · 0.65
CapabilitiesMethod · 0.65
GetTypeMethod · 0.45

Tested by

no test coverage detected