How to check using Massive ORM?

I like Rails, and so Rob Conery Massive ORM attracts me like ... well, very rail.

My question is, how exactly can and should you do validations using Massive? In Rails, you can use the simple "validates" keyword to perform built-in validations and / or reference the invocation method ... along with the ability to determine when such validation occurs (for example, to create only after saving, etc.). .).

Are such Rails inspirational checks available with Massive? If so, what is the recommended approach?

Thank you very much -wg

+6
source share
5 answers

Validations were recently added to Massive according to ReadMe on GitHub.

+1
source

I was wondering about the same thing today, I still don’t have a satisfactory answer, but I found code sample for the Tekpub MVC 3 series, which has recently been ported to Github and uses Massive to access data -

https://github.com/tekpub/mvc3

This class includes some DataAnnotation checks against view models because, as far as I can see, none of the "domain" classes include any checks.

+2
source

With Asp.net MVC, the most recommended approach is to test the use of DataAnnotations or FluentValidations. There is a lot of knowledge out there if you simply advertise these terms.

Us Seesharpies prefer not to test database models, so we can have a clear separation of problems. Checking database models is not “wrong,” but with the rigidity of a static and compiled language, other alternative approaches simply don't make much sense.

+1
source

I would not have done validation with Massive. For my domain model, I have a DTO “team” that use DataAnnotations. My domain object validates them, and then I use the "domain event" template to post changes to my aggregates.

Here, where I will use massive - subscribers listening to my domain will process the DTO events that will be raised and use them to update the database through the array. Then my model will use an array to query the database.

I use EF 4.1 and I don't like to match the command -> event -> view model / dto. I will use an array, so I no longer need to define a / dto view model.

+1
source

doing the check is no different than how to do it with EF .. this means commenting on the above answer.

If you are familiar with DataAnnotations, you know how to do validation. Assuming you have viewmodels, add annotations to them. In your controllers, you work with viewmodels, where validation is performed. When checking, you pass them to your data layer, which can be massive or ef or something else.

to be clear, you are not testing entities that you are testing in view models. Hope this makes sense! I almost do not understand this hahahahaha myself.

0
source

Source: https://habr.com/ru/post/892372/


All Articles