views:

310

answers:

1

I am using Symfony 1.3.2 with Propel ORM on Ubuntu 9.10.

I am writing a registration form, which requires a user to provide a user name.

I want to impose the following restrictions on the choice of names:

  1. That the name is unique (i.e. is not already in use by someone else
  2. The name is not in a list of offensive names, stored in a database table

For the first requirement, it is easily done by using the sfValidatorPropelUnique validator.

The challenge however lies in implementing the second requirement AND COMBINING requirement 1 and 2 into a single validator.

I suppose I could write a custom validator to do this, but I am wondering is there a better way to do this (i.e. using the framework, and not "rolling my own" solution ?

A: 

Can't think of a ready symfony validator solution to do that, and in any case, you'd need to write the database call separately.

I'd go with 'rolling your own solution' but perhaps someone more experienced has a better idea.

There's something in this doc about Propel autocomplete which might give you some ideas if you're minded to explore further:

http://www.symfony-project.org/cookbook/1_2/en/make-a-choice

... courtesy of the sfFromExtraPlugin, but I'm not even sure if that's 1.3 compatible.

Tom