[FLOW3-general] Problem with validation

"Christian Müller (FLOW3 Team)" christian.mueller at typo3.org
Tue Apr 10 18:18:34 CEST 2012


Hi,

yes it's true that is the state of the art. You need to add the notEmpty 
validator too if you want to prevent empty values, we found that having 
a restriction on the content may not be the same as wanting content at 
all. See for example the email address validation, you might want to 
have an email address in a certain property but it is not required to 
fill it at all.

Sure StringLength with minimum 1 is kind of an edge case, but still it 
is clearer to have both.

Cheers,
Christian

On 10/04/12 17:38, Martin wrote:
> I found a strange a solution but, is this state of the art?
>
> The @FLOW3\Validate(type="StringLength", options={ "minimum"=1,
> "maximum"=200 })
>
> --> minimum does not work for empty Forms therefore u have to add:
> @FLOW3\Validate(type="notEmpty")
>
> to get an empty Form validate, after that u can specify your the minimum
> and maximum...
>
> For my point of view it should be included in the minimum check!
>
> Greetz
>
> Martin
>
>
>
>
> On 04/10/2012 02:48 PM, Martin wrote:
>> Dear List,
>>
>> I am trying to implement standard validation. But th eobject is still
>> created without any errors. I manly followed the Blog example on the
>> Definite Guide an on the git repository.
>>
>> Can someone give me a clue what is wrong or if I have to enable
>> validation. I recreated the Database and emptied the cache
>> severaltimes...
>>
>> Thanx alot!
>>
>> Martin
>>
>> My Model with:
>>
>> /**
>> * The theme
>> * @var string
>> * @FLOW3\Validate(type="StringLength", options={ "minimum"=1,
>> "maximum"=200 })
>> * @ORM\Column(length=200)
>> */
>> protected $theme;
>>
>> in the Model.
>>
>> In the view I am having:
>>
>> <f:form action="create" name="newSeminar" object="{newSeminar}"
>> enctype="multipart/form-data">
>>
>>
>> and my renderings:
>>
>> <f:render partial="FormErrors" arguments="{for: 'newSeminar'}" />
>>
>> The Partial looks like:
>>
>>
>> <f:form.validationResults for="{for}">
>> <f:if condition="{validationResults.flattenedErrors}">
>> <dl class="errors">
>> <f:for each="{validationResults.flattenedErrors}" key="propertyPath"
>> as="errors">
>> <dt>
>> {propertyPath}:
>> </dt>
>> <dd>
>> <f:for each="{errors}" as="error">{error}</f:for>
>> </dd>
>> </f:for>
>> </dl>
>> </f:if>
>> </f:form.validationResults>
>>



More information about the FLOW3-general mailing list