mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
This introduces the concept of validation errors, where we have a high
level validation error which wraps a more detailed error message.
The higher level `ValidationError` is set up in the generated files, much
like the `NotFoundError` and `ConstraintError` and is accompanied by an
`IsValidationError` check method. Thus, it can be used as follows:
```go
t, err := tx.Team.Create().SetName(input.Name).Save(ctx)
if ent.IsValidationError(err) {
// handle validation error response
}
```
User-Spouse Bidirectional O2O Relation
An example for a reflexive O2O relation between a User to its spouse (also a User).
Each user can have only one spouse. If a user A sets its spouse (using spouse) to B,
B can get its spouse using the spouse edge.
Generate Assets
go generate ./...
Run Examples
go test