Validator 'required="true"' doesn't work. #473

nusov opened this Issue Sep 24, 2012 · 2 comments


None yet
3 participants

nusov commented Sep 24, 2012

I've created the schema with 'required="true"' attributes (from manual)..
but when i do

$item = new Item();

it saves with no errors!

<?xml version="1.0" encoding="UTF-8"?>
<database name="start" defaultIdMethod="native">
  <table name="book" phpName="Book">
    <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
    <column name="title" type="varchar" size="255" required="true" />
    <column name="isbn" type="varchar" size="24" required="true" phpName="ISBN"/>
    <column name="publisher_id" type="integer" required="true"/>
    <column name="author_id" type="integer" required="true"/>
    public function indexAction()
        $book = new Book();

instead of any exception i get a row where fields filled with ''

I tried to debug SQL and propel produces SQL INSERT with just ID field

Hope this makes sense.

nusov commented Sep 24, 2012

BTW - $book->validate() returns true


jaugustin commented Sep 24, 2012

required has nothing to do with the validator, but only tell MySQL to create a column NOT NULL.

For validator you need to add validator rules :

<column name="username" type="VARCHAR" size="25" required="true" />
<validator column="username">
  <rule name="required" message="Username is required." />

@willdurand willdurand closed this Nov 4, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment