Validation

Topics: General
Jul 22, 2015 at 8:23 AM
Hi,

I created the class as

public class MapPart : ContentPart<MapRecord>
{
    [Required]
    public double Latitude
    {
        get { return Retrieve(r => r.Latitude); }
        set { Store(r => r.Latitude, value); }
    }

    [Required]
    public double Longitude
    {
        get { return Retrieve(r => r.Longitude); }
        set { Store(r => r.Longitude, value); }
    }
}
When I include this(MapPart) in one of the Content type and Submit the form in (Admin Section).It is allowing me to create a content type even without entering values in these two boxes. Default value in textbox is 0.

How we do validation in orchard so that without entering those values one should not be able to submit the form?
Developer
Jul 23, 2015 at 3:32 PM
You would do the model validation in the Editor method of your driver class, adding model state errors via the updater object.
Marked as answer by Kevinpiper123 on 7/26/2015 at 3:52 PM