Mikko

A) This from docs

http://127.0.0.1:1972/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_datatypes#GOB
J_C2748

DisplayToLogical - converts a variety of display values into appropriate
logical values.
IsValidDT - performs data validation for the value associated with a
property. The method returns 1 as the first character if the value is valid
and 0 as the first character if it is not valid. When validation is enabled,
the IsValidDT method is invoked automatically.
LogicalToDisplay - converts a logical value to a display value.
LogicalToOdbc - converts a logical value into an ODBC value (optional).
LogicalToStorage - converts a logical value into a storage value (optional).
OdbcToLogical - converts a logical value into a storage value (optional).
StorageToLogical - converts a database storage value into a logical value
(optional).

B) From Class Reference %Date

classmethod IsValidDT(%val As %Date) returns %Integer
Tests if the logical value %val, which represents a date in $H format, is
valid. The validation is based on the class parameter settings used for the
class attribute this data type is associated with.

In this case, MAXVAL and MINVAL.

Returns true (1) if the value %val is valid, otherwise false (0).

HTH

Regards
Sukesh



Mikko Harjula <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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



Reply via email to