On Wed, Nov 18, 2009 at 6:14 AM, Ferdinand Chan <[email protected]> wrote:
> If I have a model "Item" as follows,
>
> class Item extends LongKeyedMapper[Item] with IdPK{
>
> def getSingleton = Item
>
> object chiBrandName extends MappedPoliteString(this,255)
>
> object engBrandName extends MappedPoliteString(this,255)
>
override def validate : List[FieldError] = runSafe {
myLocalValidation // returns List[FieldError]
} ::: super.validate
def myLocalValidation: List[FieldError] = ... do your multi-field logic
here
> }
>
>
> An item is valid if and only if at least one of the brand name is non-
> empty.
>
> But from the lift example, field validation is done by overriding the
> validations method of each field and the validate method of the
> LongKeyedMetaMapper will invoke all validations method of its fields
> and return the list of FieldError if any.
>
> Is there anyway to implement my requirement in lift Mapper with
> something like (Sorry for my bad lift syntax, still learning :) )
>
> def isValidItem = {
> if ( (chiBrandName eq null) || chiBrandName.length == 0) &&
> (engBrandName eq null) || engBrandName.length == 0) )
> // show the field error
> else Nil
> }
>
> Thanks
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=.
>
>
>
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
--
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=.