[web2py] Re: Date field mask or another value

2012-03-29 Thread Derek
 is certainly a valid year. 99 could be a valid calendar month, 
depending on your calendar. You should probably specify what the valid 
range of values are.
Try the IS_MATCH with a regex.

On Tuesday, March 27, 2012 8:05:11 AM UTC-7, Adriano Almeida wrote:
>
> Hi, 
>
> I want a field (may be string,date or number, no prob) to have a 
> format of MM (valid year and month) or if it is left null, to be 
> 99. How Could I accomplished that? 
>
> I have tried : 
> Field('A0514_DT_FIN','date',notnull=True, label= 'Dt Fim (MM)', 
> default= '99') 
>
> and then the check: 
> db.tb0514_bihc_consultor_nivel.A0514_DT_FIN.requires = 
> IS_EMPTY_OR(IS_DATE(format=T('%Y%m'), error_message='formato deve ser 
> MM! ou vazio')) 
>
> It does not work as 99 is not a valid month and  is not a valid 
> year. 
>
> Any ideas? 
>
>

[web2py] Re: Date field mask or another value

2012-03-27 Thread Massimo Di Pierro
Does it need to be a date field? It not have a day so it will create some 
problems. You can make it a string field

Field('A0514_DT_FIN',requires=IS_EMPTY_OR(IS_MATCH('\d{6}')))




On Tuesday, 27 March 2012 10:05:11 UTC-5, Adriano Almeida wrote:
>
> Hi, 
>
> I want a field (may be string,date or number, no prob) to have a 
> format of MM (valid year and month) or if it is left null, to be 
> 99. How Could I accomplished that? 
>
> I have tried : 
> Field('A0514_DT_FIN','date',notnull=True, label= 'Dt Fim (MM)', 
> default= '99') 
>
> and then the check: 
> db.tb0514_bihc_consultor_nivel.A0514_DT_FIN.requires = 
> IS_EMPTY_OR(IS_DATE(format=T('%Y%m'), error_message='formato deve ser 
> MM! ou vazio')) 
>
> It does not work as 99 is not a valid month and  is not a valid 
> year. 
>
> Any ideas? 
>
>