func (tu *TodoUpdate) check() error {
	if v, ok := tu.mutation.Status(); ok {
		if err := todo.StatusValidator(v); err != nil {
			return &ValidationError{Name: "status", err: fmt.Errorf("ent: validator failed for field \"status\": %w", err)}
		}
	}
	if v, ok := tu.mutation.Text(); ok {
		if err := todo.TextValidator(v); err != nil {
			return &ValidationError{Name: "text", err: fmt.Errorf("ent: validator failed for field \"text\": %w", err)}
		}
	}
	return nil
}
check runs all checks and user-defined validators on the builder.
package ent
import (
	"context"
	"fmt"
	"entgo.io/contrib/entgql/internal/todo/ent/category"
	"entgo.io/contrib/entgql/internal/todo/ent/predicate"
	"entgo.io/contrib/entgql/internal/todo/ent/todo"
	"entgo.io/contrib/entgql/internal/todo/ent/verysecret"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type TodoUpdate struct {
	config
	hooks    []Hook
	mutation *TodoMutation
}
func (tu *TodoUpdate) Where(ps ...predicate.Todo) *TodoUpdate {
	tu.mutation.Where(ps...)
	return tu
}
func (tu *TodoUpdate) SetStatus(t todo.Status) *TodoUpdate {
	tu.mutation.SetStatus(t)
	return tu
}
func (tu *TodoUpdate) SetPriority(i int) *TodoUpdate {
	tu.mutation.ResetPriority()
	tu.mutation.SetPriority(i)
	return tu
}
func (tu *TodoUpdate) SetNillablePriority(i *int) *TodoUpdate {
	if i != nil {
		tu.SetPriority(*i)
	}
	return tu
}
func (tu *TodoUpdate) AddPriority(i int) *TodoUpdate {
	tu.mutation.AddPriority(i)
	return tu
}
func (tu *TodoUpdate) SetText(s string) *TodoUpdate {
	tu.mutation.SetText(s)
	return tu
}
func (tu *TodoUpdate) SetBlob(b []byte) *TodoUpdate {
	tu.mutation.SetBlob(b)
	return tu
}
func (tu *TodoUpdate) ClearBlob() *TodoUpdate {
	tu.mutation.ClearBlob()
	return tu
}
func (tu *TodoUpdate) SetParentID(id int) *TodoUpdate {
	tu.mutation.SetParentID(id)
	return tu
}
func (tu *TodoUpdate) SetNillableParentID(id *int) *TodoUpdate {
	if id != nil {
		tu = tu.SetParentID(*id)
	}
	return tu
}
func (tu *TodoUpdate) SetParent(t *Todo) *TodoUpdate {
	return tu.SetParentID(t.ID)
}
func (tu *TodoUpdate) AddChildIDs(ids ...int) *TodoUpdate {
	tu.mutation.AddChildIDs(ids...)
	return tu
}
func (tu *TodoUpdate) AddChildren(t ...*Todo) *TodoUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tu.AddChildIDs(ids...)
}
func (tu *TodoUpdate) SetCategoryID(id int) *TodoUpdate {
	tu.mutation.SetCategoryID(id)
	return tu
}
func (tu *TodoUpdate) SetNillableCategoryID(id *int) *TodoUpdate {
	if id != nil {
		tu = tu.SetCategoryID(*id)
	}
	return tu
}
func (tu *TodoUpdate) SetCategory(c *Category) *TodoUpdate {
	return tu.SetCategoryID(c.ID)
}
func (tu *TodoUpdate) SetSecretID(id int) *TodoUpdate {
	tu.mutation.SetSecretID(id)
	return tu
}
func (tu *TodoUpdate) SetNillableSecretID(id *int) *TodoUpdate {
	if id != nil {
		tu = tu.SetSecretID(*id)
	}
	return tu
}
func (tu *TodoUpdate) SetSecret(v *VerySecret) *TodoUpdate {
	return tu.SetSecretID(v.ID)
}
func (tu *TodoUpdate) Mutation() *TodoMutation {
	return tu.mutation
}
func (tu *TodoUpdate) ClearParent() *TodoUpdate {
	tu.mutation.ClearParent()
	return tu
}
func (tu *TodoUpdate) ClearChildren() *TodoUpdate {
	tu.mutation.ClearChildren()
	return tu
}
func (tu *TodoUpdate) RemoveChildIDs(ids ...int) *TodoUpdate {
	tu.mutation.RemoveChildIDs(ids...)
	return tu
}
func (tu *TodoUpdate) RemoveChildren(t ...*Todo) *TodoUpdate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return tu.RemoveChildIDs(ids...)
}
func (tu *TodoUpdate) ClearCategory() *TodoUpdate {
	tu.mutation.ClearCategory()
	return tu
}
func (tu *TodoUpdate) ClearSecret() *TodoUpdate {
	tu.mutation.ClearSecret()
	return tu
}
func (tu *TodoUpdate) Save(ctx context.Context) (int, error) {
	var (
		err      error
		affected int
	)
	if len(tu.hooks) == 0 {
		if err = tu.check(); err != nil {
			return 0, err
		}
		affected, err = tu.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*TodoMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			if err = tu.check(); err != nil {
				return 0, err
			}
			tu.mutation = mutation
			affected, err = tu.sqlSave(ctx)
			mutation.done = true
			return affected, err
		})
		for i := len(tu.hooks) - 1; i >= 0; i-- {
			if tu.hooks[i] == nil {
				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
			}
			mut = tu.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, tu.mutation); err != nil {
			return 0, err
		}
	}
	return affected, err
}
func (tu *TodoUpdate) SaveX(ctx context.Context) int {
	affected, err := tu.Save(ctx)
	if err != nil {
		panic(err)
	}
	return affected
}
func (tu *TodoUpdate) Exec(ctx context.Context) error {
	_, err := tu.Save(ctx)
	return err
}
func (tu *TodoUpdate) ExecX(ctx context.Context) {
	if err := tu.Exec(ctx); err != nil {
		panic(err)
	}
}