CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Validation WebService

    rated by 0 users
    This post has 6 Replies | 1 Follower

    Not Ranked
    Posts 5
    jairan Posted: Tue, Oct 1 2013 1:27 PM

    Validation rules of the attributes do not work with webservice.

     

     

    Ex :

    BusinessRules.AddRule(new Required(CodPrestadorOperadoraProperty));

     

    The field is required, but when I save generates the error 

     

    _Eleg.Save();

    " Object is not valid and can not be saved "

    Top 10 Contributor
    Posts 2,279

    I do not understand the actual issue here. 

    If the field has no value then the rule is broken, the object will have IsSavable = false and the Save method will give that exception. 

    Can you provide more details and code? 

     

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    Posts 5
    jairan replied on Wed, Oct 2 2013 7:14 AM

    Hello Jonny,

    This attribute is mandatory, the time I save should not prevent action stating that there is a required field and that it was not filled.

     

    /////

      Protected override void AddBusinessRules()

            {

                base.AddBusinessRules();

                BusinessRules.AddRule(new Csla.Rules.CommonRules.Required (CodPrestadorOperadoraProperty , () => "Codigo Obrigatorio." )  );

                BusinessRules.AddRule(new MaxLength(CodPrestadorOperadoraProperty, 10));

                BusinessRules.AddRule(new MinLength(CodPrestadorOperadoraProperty, 2));

            }

    ////

     

    //// Save

    _Eleg.CodPrestadorOperadora = null; 

    _Eleg = _Eleg.Save();  

    ////

     

     

     

    Not Ranked
    Posts 5
    jairan replied on Wed, Oct 2 2013 7:17 AM

     

    Using the WinForm, usually works.

    Now the WebService that this rule does not bar.

    Not Ranked
    Posts 5
    jairan replied on Wed, Oct 2 2013 8:52 AM

     

     

    When I use the "ErrorProvider", know what the error is.

     

    When not use, do not know what error is.

    Top 10 Contributor
    Posts 2,279
    JonnyBee replied on Wed, Oct 2 2013 10:54 AM

    Hi,

    The business object is not aware of any type of UI or Service.
    Csla is for business objects and not just data access code. 

    If the object has broken rules with severity ERROR the object is considered broken and you are not allowed to call Save. 

    An alternative is to change the Severity to Warning or Information. Any broken rule with these severities will NOT block Save operation. 

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    Posts 5
    jairan replied on Wed, Oct 2 2013 11:27 AM

    Understand.

    Thank you Jonny for the clarifications

    Page 1 of 1 (7 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems