EdwardJS024
Programmer
Maybe you guys can lend hand in an intuitive way to handle input validation from the client/UI.
I am working on a validation engine that validates all input data and making sure it meets a domain specification/criteria, only then is it considered a valid input.
PROBLEM:++++++++++++++++++++++++++++++++++++++++++++++++++
My only concern is, what is the best way to notify
the client that their input is invalid AND one or more
fields may have been the cause? I also want to give a
sumamry of the fields that is not valid.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DESIGN:++++++++++++++++++++++++++++++++++++++++++++++++++++
So, i decided to write Specifications that represent
fields on the UI that map to objects of the domain (yet another reason why storage persistence and UI are just export mediums, they work alike):
So:
AddressSpecification
AgeSpecification
PhoneSpecification
FirstNameSpecification
etc..
etc..
Clients can use these primitive specs in order to validate fields before submission. I then realized that maybe a composite pattern will fit nicely so i created a
CustomSpecification that represents an entire form that needs to be validated.
CustomSpecification accepts constraints via:
aCustomSpecification.Add(aSpec);
calling CustomSpecification.IsValid() will dispatch the request to all children checking for validity.
If one or more fields fail, i want to let the clients know 2 things:
1. IsValid is false
2. a summary of fields that failed (a collecton/list)?
I can't seem to put it together, i have a general idea but hopefully someone has done this before?
-EJS
I am working on a validation engine that validates all input data and making sure it meets a domain specification/criteria, only then is it considered a valid input.
PROBLEM:++++++++++++++++++++++++++++++++++++++++++++++++++
My only concern is, what is the best way to notify
the client that their input is invalid AND one or more
fields may have been the cause? I also want to give a
sumamry of the fields that is not valid.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
DESIGN:++++++++++++++++++++++++++++++++++++++++++++++++++++
So, i decided to write Specifications that represent
fields on the UI that map to objects of the domain (yet another reason why storage persistence and UI are just export mediums, they work alike):
So:
AddressSpecification
AgeSpecification
PhoneSpecification
FirstNameSpecification
etc..
etc..
Clients can use these primitive specs in order to validate fields before submission. I then realized that maybe a composite pattern will fit nicely so i created a
CustomSpecification that represents an entire form that needs to be validated.
CustomSpecification accepts constraints via:
aCustomSpecification.Add(aSpec);
calling CustomSpecification.IsValid() will dispatch the request to all children checking for validity.
If one or more fields fail, i want to let the clients know 2 things:
1. IsValid is false
2. a summary of fields that failed (a collecton/list)?
I can't seem to put it together, i have a general idea but hopefully someone has done this before?
-EJS