Monorepo for Tangled tangled.org
752
fork

Configure Feed

Select the types of activity you want to include in your feed.

proposal: make models self-validate and remove Validator #121

open opened by boltless.me

Currently validation logic is done from Validator object. We can make models self-validate themselves.

Below is schema of Validator:

type Validator struct {
	db        *db.DB
	sanitizer markup.Sanitizer
	resolver  *idresolver.Resolver
	enforcer  *rbac.Enforcer
}
  • we don't need db validation because in atproto, the target object might not be ingested yet.
  • we do need to perform sanitizing check, but we can make singleton for these instead. (we are using just markup.NewSanitizer())
  • we don't need did validation because of similar reason. syntax level check is enough.
  • we do need to perform rbac check, but we are already doing it in most places without using centralized Validator object.

Therefore, I think we don't need a struct to group validation dependencies.

Let's ditch most of the dependencies needed to validate the model and just call Issue.Validate() instead.

+1 from me. Makes sense.

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.issue/3m7i45kp53z22