Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In MVP where to write validations

Tags:

mvp

In Model-View-Presenter pattern where should we write validations of user input.

like image 265
Prabu Avatar asked Oct 20 '08 08:10

Prabu


People also ask

How do you validate an MVP?

Not unlike Crowdfunding, Pre-Order pages have proven a very effective way to validate your MVP, often, before you even build it. Oculus Rift is a prime example of this method being utilized as they released a pre-order page for their development kit before they even began production of them.

What is MVP with validation?

A minimum viable product, or MVP, is a product with enough features to attract early-adopter customers and validate a product idea early in the product development cycle. In industries such as software, the MVP can help the product team receive user feedback as quickly as possible to iterate and improve the product.

Where should form validation occur?

In general, it is best to perform input validation on both the client side and server side. Client-side input validation can help reduce server load and can prevent malicious users from submitting invalid data.

What are the different types of input validation?

There are two different types of input validation approaches: whitelist validation (sometimes referred to as inclusion or positive validation) and blacklist validation (sometimes known as exclusion or negative validation).


1 Answers

Domain specific rules/validations should be in the Model. You can have a model.validate() to let you know if the rules are not violated. Look at Rails model (ActiveRecord) classes for a good implementation of this concept.

The View should make it difficult for the user to key in invalid input. So 'entering a string for a numeric value' class of input errors should be nipped before reaching the presenter. There may be some duplication of validations between model and view. E.g. AttributeX must range between 1-100. This must be validated in the model.. at the same time you may want to slot in a spinner in the UI with the minValue and maxValue range set to 1-100.

like image 124
Gishu Avatar answered Oct 02 '22 13:10

Gishu