1

I am using Propel schema to create database tables. In a table, i need to create a 'name' column which should hold a 'short string', 'all in lower case', and 'with no spaces', for example: 'join', 'appointment'.

How can I define this column in schema.xml with given constraints? Or do I have to create a custom validator to get it done?

bassplayer7
  • 924
  • 1
  • 13
  • 38
Meelan
  • 70
  • 6

1 Answers1

1

You can define a validate behaviour in your schema.xml.

There are several validators to choose from, you would probably use the Choice Validator.

Example:

<table name='TableName'>
  ...
  <column name='name' type='varchar' size='20' />
  <behavior name="validate">
    <parameter name="rule1" value="{column: name, validator: Choice, options: {message: Please enter a valid name }}" />
  </behavior>
</table> 
Qiniso
  • 2,587
  • 1
  • 24
  • 30