How and where to validate form controls that match the fields in my database?

Asked

Viewed 19 times

1

I have the following problem: I need to validate my controls (textbox, combobox, etc) that correspond to the fields of my table, for example, on my screen I have the txtBairro control, in which the data that will be entered there will be persisted in the Neighborhood field of my table in the database.

I am managing my bank via code (Code First) + Entity Framework, in which I started using reverse engineering. If in the mapping of my database I already have validations (Fluent API and Dataannotations), I should not validate the controls of my form again, because it would be rework. The question that arises to me is this: how can I use these validations that the framework itself provided me with reverse engineering to validate the controls of my form as well?

  • Let’s go by parts... if it was done a "reverse engineering" is DB First, who came before? What type of application is it? How is the model bind with the controls? Edit your question by presenting a [MCVE]

1 answer

0

Abner, The question is broader than a simple rework when validating the fields before sending to the bank. Imagine the work behind it to make all the information reach the database and be validated only there.

Validating customer data prevents all this work and still improves end-user experience.

You also have to consider the most important. Validate the business rules. For a simple CRUD you can even consider, but for complex businesses you should think the whole before defining the strategy.

If your bank already has the validation rules, you will get this validation. It all depends on the type of project, future perspectives, if it is something bigger, with great possibility to scale, rethink the strategy.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.