Swift-Kuery-ORM icon indicating copy to clipboard operation
Swift-Kuery-ORM copied to clipboard

How to validate model attributes?

Open Morpheu5 opened this issue 6 years ago • 3 comments

I may be missing this completely, but I don't see a way of validating attributes of Models for things like uniqueness (say, user names or e-mail addresses?) and so on. Is this functionality that is not implemented / will not be implemented, or is this going to come in the future?

I'm happy to do manual validation, but it would be neat to have this supported by the ORM.

Morpheu5 avatar May 04 '18 15:05 Morpheu5

Hey @Morpheu5, unfortunately this functionality hasn't been implemented just yet. But we could definitely be willing to add it! @kilnerm could you have a look if this is a possibility?

EnriqueL8 avatar May 04 '18 19:05 EnriqueL8

Thanks for the clarification, @EnriqueL8! I'll go ahead and do my own validation for now, but I'll keep watching this space. Count me in at least for a discussion :)

Morpheu5 avatar May 05 '18 09:05 Morpheu5

Similar question. It would be nice if attributes could be added in a model! (Django does that quite well, and blurs the boundary between a table and a model)

Currently my detour is to use raw SQL to set constraints after the createTableSync() is done. E.g., ALTER TABLE "People" ADD CONSTRAINT uc_person_id UNIQUE(person_id);

yo1995 avatar Jun 27 '19 16:06 yo1995