Hi, I'm trying to use the date type(http://wiki.erlang-web.org/Wparts/BasicTypes/date) with an optional value for one of my input fields, but if I leave the field that has an optional value empty my validation fails. As long as I put a date in all fields the validation works! from my tracing:
(<0.3201.0>) call admin_utils:set_active(not_used,user_admin,admin_reports,[[]]) (<0.3201.0>) returned from admin_utils:set_active/4 -> {proceed,[[]]} (<0.3201.0>) call admin_utils:validate({admin_report,create},user_admin,admin_reports,[[]]) (<0.3201.0>) call wtype_date:validate({[{description,"End date (YYYYMMDD)"},{format,"YYYYMMDD"}],"20100330"}) (<0.3201.0>) call wtype_date:convert_input("YYYYMMDD","20100330",[]) (<0.3201.0>) call wtype_date:convert_input("MMDD","0330",[{year,2010}]) (<0.3201.0>) call wtype_date:convert_input("DD","30",[{month,3},{year,2010}]) (<0.3201.0>) call wtype_date:convert_input([],[],[{day,30},{month,3},{year,2010}]) (<0.3201.0>) returned from wtype_date:convert_input/3 -> {2010,3,30} (<0.3201.0>) returned from wtype_date:convert_input/3 -> {2010,3,30} (<0.3201.0>) returned from wtype_date:convert_input/3 -> {2010,3,30} (<0.3201.0>) returned from wtype_date:convert_input/3 -> {2010,3,30} (<0.3201.0>) call wtype_date:check_min([{description,"End date (YYYYMMDD)"},{format,"YYYYMMDD"}],{2010,3,30}) (<0.3201.0>) returned from wtype_date:check_min/2 -> {ok,{2010,3,30}} (<0.3201.0>) call wtype_date:check_max([{description,"End date (YYYYMMDD)"},{format,"YYYYMMDD"}],{2010,3,30}) (<0.3201.0>) returned from wtype_date:check_max/2 -> {ok,{2010,3,30}} (<0.3201.0>) returned from wtype_date:validate/1 -> {ok,{2010,3,30}} (<0.3201.0>) call wtype_date:validate({[{description,"Start date (YYYYMMDD)"}, {format,"YYYYMMDD"}, {optional,{2010,3,29}}], []}) (<0.3201.0>) call wtype_date:convert_input("YYYYMMDD",[],[]) (<0.3201.0>) returned from wtype_date:convert_input/3 -> {error,bad_format} (<0.3201.0>) returned from wtype_date:validate/1 -> {error, {bad_date_format,[]}} (<0.3201.0>) returned from admin_utils:validate/4 -> {error, {user_admin, validate_error, [admin_reports]}} (<0.3201.0>) call wtype_date:get_date("YYYY-MM-DD","20100330") (<0.3201.0>) returned from wtype_date:get_date/2 -> "20100330" and my admin_report.hrl -record(admin_report, { start_date, start_time, end_date, end_time}). -record(admin_report_types, { start_date = {date, [ {description, "Start date (YYYYMMDD)"} , {format, "YYYYMMDD"} , {optional, {2010,03,29}} ]} , start_time = {time, [ {description, "Start time (HHMMSS)"} , {format, "HHMMSS"} ]} , end_date = {date, [ {description, "End date (YYYYMMDD)"} , {format, "YYYYMMDD"} ]} , end_time = {time, [ {description, "End time (HHMMSS)"} , {format, "HHMMSS"} ]}}). any ideas? Cheers, Anders Karlsson --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Erlangweb-users mailing list Erlangweb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/erlangweb-users http://www.erlang-web.org/