Discussion:
[Erp5-dev] Validation of multiple fields on one form
Mikolaj Antoszkiewicz
2008-04-16 13:41:15 UTC
Permalink
Hello,

I've just came across such an issue:

I'm trying to validate if a given user (actually a pair First+Last Name)
was already saved (used) in the system.

Well, the problem is that I'd like to check both fields at the same
time, but the validating script gets only a field value from the field
it's attached to.
I've used the Request object passed also to the validating script, to
get both last and first name values, but it looks a bit ugly.

Is there any 'nicer' way of doing such a validation?

Mikolaj
Łukasz Nowak
2008-04-16 13:52:39 UTC
Permalink
Hello,

On 2008-04-16, 15:41:15
Post by Mikolaj Antoszkiewicz
Hello,
I'm trying to validate if a given user (actually a pair First+Last
Name) was already saved (used) in the system.
Well, the problem is that I'd like to check both fields at the same
time, but the validating script gets only a field value from the
field it's attached to.
I've used the Request object passed also to the validating script, to
get both last and first name values, but it looks a bit ugly.
Is there any 'nicer' way of doing such a validation?
As far as I understood you are trying to validate data of object, using
user interface?

Wouldn't it be nicer to use proper Constraint for this type, and invoke
checkConsistency while validating object?

Using mass workflow transition with some asynchronous messaging would
give possibility to:
a mass data insertion
b then mass data validation
c mass data edition, goto b until wrong objects left

And there might be some kind of tooltip on object, which would show
checkConsistency messages on object, while edited by user (eg. list
presence of duplications etc).

That's a way, we are implementing such constraining in our
implementation.

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Mikolaj Antoszkiewicz
2008-04-16 14:12:59 UTC
Permalink
Post by Mikolaj Antoszkiewicz
Hello,
On 2008-04-16, 15:41:15
Post by Mikolaj Antoszkiewicz
Hello,
I'm trying to validate if a given user (actually a pair First+Last
Name) was already saved (used) in the system.
Well, the problem is that I'd like to check both fields at the same
time, but the validating script gets only a field value from the
field it's attached to.
I've used the Request object passed also to the validating script, to
get both last and first name values, but it looks a bit ugly.
Is there any 'nicer' way of doing such a validation?
As far as I understood you are trying to validate data of object, using
user interface?
Wouldn't it be nicer to use proper Constraint for this type, and invoke
checkConsistency while validating object?
Well, sure, but I doubt You'll find a user which has to enter daily and
in a hurry, few Persons and then an Event or two for each of them, to
validate each Person with the workflow transition.

Also, after it's been successfully validated, Person object is still
editable - so much for consistency check.

Sure, it could be read-only after validation, but then each and every
small change to it's details, would mean two additional transitions (at
least 7 clicks - if everything is valid :) ). So in a case where there
is a need for a 'mass' change in a group of Persons, I can picture a
regular user throwing a computer through the window and jumping after it
after first 30 cliks...
Post by Mikolaj Antoszkiewicz
Using mass workflow transition with some asynchronous messaging would
a mass data insertion
b then mass data validation
c mass data edition, goto b until wrong objects left
No mass data operations on Person type objects is to be expected here.
Post by Mikolaj Antoszkiewicz
And there might be some kind of tooltip on object, which would show
checkConsistency messages on object, while edited by user (eg. list
presence of duplications etc).
At which point that tooltip would appear?
Post by Mikolaj Antoszkiewicz
That's a way, we are implementing such constraining in our
implementation.
Regards,
Luke
Anyway, You haven't mentioned what is 'not nice' in my approach? Field
validators are there exactly for validation of data using user interface.

Regards,
Mikolaj
Łukasz Nowak
2008-04-17 09:25:34 UTC
Permalink
Hello,

On 2008-04-16, 16:12:59
Post by Mikolaj Antoszkiewicz
Post by Mikolaj Antoszkiewicz
Hello,
On 2008-04-16, 15:41:15
Post by Mikolaj Antoszkiewicz
Hello,
I'm trying to validate if a given user (actually a pair First+Last
Name) was already saved (used) in the system.
Well, the problem is that I'd like to check both fields at the
same time, but the validating script gets only a field value from
the field it's attached to.
I've used the Request object passed also to the validating script,
to get both last and first name values, but it looks a bit ugly.
Is there any 'nicer' way of doing such a validation?
As far as I understood you are trying to validate data of object,
using user interface?
Wouldn't it be nicer to use proper Constraint for this type, and
invoke checkConsistency while validating object?
Well, sure, but I doubt You'll find a user which has to enter daily
and in a hurry, few Persons and then an Event or two for each of
them, to validate each Person with the workflow transition.
Also, after it's been successfully validated, Person object is still
editable - so much for consistency check.
Sure, it could be read-only after validation, but then each and every
small change to it's details, would mean two additional transitions
(at least 7 clicks - if everything is valid :) ). So in a case where
there is a need for a 'mass' change in a group of Persons, I can
picture a regular user throwing a computer through the window and
jumping after it after first 30 cliks...
Post by Mikolaj Antoszkiewicz
Using mass workflow transition with some asynchronous messaging
a mass data insertion
b then mass data validation
c mass data edition, goto b until wrong objects left
No mass data operations on Person type objects is to be expected here.
Post by Mikolaj Antoszkiewicz
And there might be some kind of tooltip on object, which would show
checkConsistency messages on object, while edited by user (eg. list
presence of duplications etc).
At which point that tooltip would appear?
All the time. As readonly field on view.
Post by Mikolaj Antoszkiewicz
Post by Mikolaj Antoszkiewicz
That's a way, we are implementing such constraining in our
implementation.
Regards,
Luke
Anyway, You haven't mentioned what is 'not nice' in my approach?
Field validators are there exactly for validation of data using user
interface.
AFAIK you are validating object data in UI. What about if you provide
another form, or dialog in which you forget to validate that data?

But as generic idea: I thinking only about convention, that data shall
be validated on data layer, not on user interface layer. Checking for
proper values in fields (eg. proper date in DateTimeField) is something
else.

I think I *feel* what is the problem, and this is related with
limitation of UI based on HTTP without some kind of client-side helper
(eg. AJAX). You need to provide information based on data gathered in
system, and let user to be able to make fast (1-2 sec), on-click,
decision. So what you suggested might be acceptable workaround, until
user-friendly generic layer would come :)

Just thinking, as we had similar problems.

Regards,
Luke
--
?ukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.
Mikolaj Antoszkiewicz
2008-04-17 09:48:07 UTC
Permalink
Post by Mikolaj Antoszkiewicz
Hello,
On 2008-04-16, 16:12:59
Post by Mikolaj Antoszkiewicz
Post by Mikolaj Antoszkiewicz
Hello,
On 2008-04-16, 15:41:15
Post by Mikolaj Antoszkiewicz
Hello,
I'm trying to validate if a given user (actually a pair First+Last
Name) was already saved (used) in the system.
Well, the problem is that I'd like to check both fields at the
same time, but the validating script gets only a field value from
the field it's attached to.
I've used the Request object passed also to the validating script,
to get both last and first name values, but it looks a bit ugly.
Is there any 'nicer' way of doing such a validation?
As far as I understood you are trying to validate data of object,
using user interface?
Wouldn't it be nicer to use proper Constraint for this type, and
invoke checkConsistency while validating object?
Well, sure, but I doubt You'll find a user which has to enter daily
and in a hurry, few Persons and then an Event or two for each of
them, to validate each Person with the workflow transition.
Also, after it's been successfully validated, Person object is still
editable - so much for consistency check.
Sure, it could be read-only after validation, but then each and every
small change to it's details, would mean two additional transitions
(at least 7 clicks - if everything is valid :) ). So in a case where
there is a need for a 'mass' change in a group of Persons, I can
picture a regular user throwing a computer through the window and
jumping after it after first 30 cliks...
Post by Mikolaj Antoszkiewicz
Using mass workflow transition with some asynchronous messaging
a mass data insertion
b then mass data validation
c mass data edition, goto b until wrong objects left
No mass data operations on Person type objects is to be expected here.
Post by Mikolaj Antoszkiewicz
And there might be some kind of tooltip on object, which would show
checkConsistency messages on object, while edited by user (eg. list
presence of duplications etc).
At which point that tooltip would appear?
All the time. As readonly field on view.
Post by Mikolaj Antoszkiewicz
Post by Mikolaj Antoszkiewicz
That's a way, we are implementing such constraining in our
implementation.
Regards,
Luke
Anyway, You haven't mentioned what is 'not nice' in my approach?
Field validators are there exactly for validation of data using user
interface.
AFAIK you are validating object data in UI. What about if you provide
another form, or dialog in which you forget to validate that data?
Well, You got a point here...
Post by Mikolaj Antoszkiewicz
But as generic idea: I thinking only about convention, that data shall
be validated on data layer, not on user interface layer. Checking for
proper values in fields (eg. proper date in DateTimeField) is something
else.
Once more, You're absolutely right. but in case of a web-based
application it's just too rough (from the user point of view) to do it
with data layer validation.
Post by Mikolaj Antoszkiewicz
I think I *feel* what is the problem, and this is related with
limitation of UI based on HTTP without some kind of client-side helper
(eg. AJAX). You need to provide information based on data gathered in
system, and let user to be able to make fast (1-2 sec), on-click,
decision. So what you suggested might be acceptable workaround, until
user-friendly generic layer would come :)
Just thinking, as we had similar problems.
Regards,
Luke
Loading...