[Seaside] [Magritte] Multiple descriptions validation/condition

Lukas Renggli renggli at gmail.com
Wed Nov 29 07:23:18 UTC 2006

> But how can i validate the unicity of an object in a collection but
> inside a description? is this possible? the idea is to keep the
> validation inside the description throw addContition:labelled:

Depends on your actual setup. In MAMultipleOptionDescription there is
a #distinct: property that enforces uniqueness by using a Set.

If you have a MAToManyRelationDescription you can add a condition like:

     [ :coll | coll asSet size = coll size ]

If you want to check if an object is not existing yet (such as the
sub-domain name of a seasidehosting.st account), you can use something
like that:

	^ (MAStringDescription selector: #name label: 'Name' priority: 10)
		addCondition: [ :value | value size > 2 ] labelled: 'The site-name
is too short, please use a longer one';
		addCondition: [ :value | value isValidSiteName ] labelled: 'The
site-name is invalid, please only use alpha-nummerical characters';

		" here we check for the uniqueness of the domain name "
		addCondition: [ :value | (SHRoot default accounts includesKey: value
asLowercase) not or: [ SHSettings serviceDirectory includesKey: value
asLowercase ] ] labelled: 'The name is already taken, please choose a
different one';


Hope this helps,

Lukas Renggli

More information about the Seaside mailing list