I cannot manage to have my datatype class property validated. I have
defined my datatype class as:
Class my.Date Extends %Date [ ClassType = datatype, ProcedureBlock ]
{
ClassMethod LogicalToDisplay(%val As %Date) As %String
{
quit $zdate(%val,3)
}
ClassMethod DisplayToLogical(%val As %String) As %Date
{
quit $$d2horo^util(%val,0)
}
ClassMethod IsValidDT(%val As %Date) As %Integer
{
if ($$d2horo^util(%val,"err") = "err") {
do err^log("my.Date.IsValidDT","validation failed ("_%val_")")
quit 0
}
do err^log("my.Date.IsValidDT","validation succ ("_%val_")")
quit 1
}
}
I use it with property mydate which has access methods:
Class X.Y Extends DB.Mod [ ClassType = persistent, ProcedureBlock ]
{
Property mydate As my.Date;
Method mydateGet() As %String
{
Quit ..mydateLogicalToDisplay(i%mydate)
}
Method mydateSet(Arg As %String) As %Status
{
set tmp=$$d2horo^util(Arg,"err")
if (tmp="err") {
do err^log("X.Y.mydateSet","Invalid Arg="_Arg)
quit $$$ERROR($$$GeneralError,"Invalid mydate "_Arg)
}
do err^log("X.Y.mydateSet","OK Arg="_Arg)
set i%mydate=tmp
quit $$$OK
}
}
When I save an X.Y object with an invalid date then %Save() saves OK
and my.Date.IsValidDT is never called. With OK date I get message
from the Set-method in the log:
2004-09-01 20:35:24, at X.Y.mydateSet in STWORK
* OK Arg=2004-07-31
2004-09-01 20:35:24, at DB.Mod.OnPreHTTP in STWORK
* %Save succeeded, sc=1
and with invalid one I get:
2004-09-01 20:36:14, at X.Y.mydateSet in STWORK
* Invalid Arg=2004-07-32
2004-09-01 20:36:14, at DB.Mod.OnPreHTTP in STWORK
* %Save succeeded, sc=1
But nothing from the IsValidDT of my.Date. What am I doing wrong
here? Isn't the validation of a property supposed to be called
automatically?
--
Mikko Harjula tel. +358-3-316 7552
[EMAIL PROTECTED] mobile +358-40-778 6669