jeudi 3 mars 2016

Maintenance validation requirements in web app

Is there any way to facilitate maintenace of validation rules in web application. What the problem? Lets say i have Note object with text field called for example body. Now if i want to restrict that field to only 500 letters what i need to do:

  1. Set constraint on database (@Column(length=500))
  2. Use hibernate validator to validation on server side @Size(500)
  3. In my textfield in HTML i can use maxlength=500
  4. In my javascript validation i also have to keep that 500 value in some way

Ad2) If i have for example NoteEntity and NoteDto/NoteModel objects its possible i also need to duplicate those constraints..

So there are at least 4 places where i have hardcoded size value, do you have any ideas how to enhance it?

Aucun commentaire:

Enregistrer un commentaire