• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Validator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Validator的典型用法代码示例。如果您正苦于以下问题:C# Validator类的具体用法?C# Validator怎么用?C# Validator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Validator类属于命名空间,在下文中一共展示了Validator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: btnOK_Click

    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        CheckConfigurationModification();

        string errorMessage = new Validator()
            .NotEmpty(txtInternalStatusDisplayName.Text.Trim(), GetString("InternalStatus_Edit.errorDisplayName"))
            .NotEmpty(txtInternalStatusName.Text.Trim(), GetString("InternalStatus_Edit.errorCodeName")).Result;

        if (!ValidationHelper.IsCodeName(txtInternalStatusName.Text.Trim()))
        {
            errorMessage = GetString("General.ErrorCodeNameInIdentificatorFormat");
        }

        if (errorMessage == "")
        {

            // Check unique name for configured site
            DataSet ds = InternalStatusInfoProvider.GetInternalStatuses("InternalStatusName = '" + txtInternalStatusName.Text.Trim().Replace("'", "''") + "' AND ISNULL(InternalStatusSiteID, 0) = " + ConfiguredSiteID, null);
            InternalStatusInfo internalStatusObj = null;
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                internalStatusObj = new InternalStatusInfo(ds.Tables[0].Rows[0]);
            }

            // if internalStatusName value is unique
            if ((internalStatusObj == null) || (internalStatusObj.InternalStatusID == mStatusid))
            {
                // if internalStatusName value is unique -> determine whether it is update or insert
                if ((internalStatusObj == null))
                {
                    // get InternalStatusInfo object by primary key
                    internalStatusObj = InternalStatusInfoProvider.GetInternalStatusInfo(mStatusid);
                    if (internalStatusObj == null)
                    {
                        // create new item -> insert
                        internalStatusObj = new InternalStatusInfo();
                        internalStatusObj.InternalStatusSiteID = ConfiguredSiteID;
                    }
                }

                internalStatusObj.InternalStatusEnabled = chkInternalStatusEnabled.Checked;
                internalStatusObj.InternalStatusName = txtInternalStatusName.Text.Trim();
                internalStatusObj.InternalStatusDisplayName = txtInternalStatusDisplayName.Text.Trim();

                InternalStatusInfoProvider.SetInternalStatusInfo(internalStatusObj);

                URLHelper.Redirect("InternalStatus_Edit.aspx?statusid=" + Convert.ToString(internalStatusObj.InternalStatusID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("InternalStatus_Edit.InternalStatusNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = errorMessage;
        }
    }
开发者ID:KuduApps,项目名称:Kentico,代码行数:63,代码来源:InternalStatus_Edit.aspx.cs


示例2: BindModel

		public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
		{
			var form = controllerContext.HttpContext.Request.Form;

			var order = new Order
			{
				//OrderStatusId = OrderStatus.CreatedId,
				CreatedDate = DateTime.Now,
				DispatchedDate = DateTime.Now
			};

			try
			{
				var validator = new Validator
				{
					() => UpdateOrder(order, form, bindingContext.ModelState),
					() => UpdateCardContact(order, form, bindingContext.ModelState),
					() => UpdateDeliveryContact(order, form, bindingContext.ModelState),
					() => UpdateCard(order, form, bindingContext.ModelState)
				};

				validator.Validate();
			}
			catch (ValidationException)
			{
				//Ignore validation exceptions - they will be stored in ModelState.
			}

		
			EnsureBasketCountryId(order);

			return order;
		}
开发者ID:bertusmagnus,项目名称:Sutekishop,代码行数:33,代码来源:OrderBinder.cs


示例3: GetDriveName

 public static string GetDriveName(string fullPath)
 {
     var validator = new Validator(fullPath);
     var drive = new DriveParser(fullPath, validator);
     validator.ThrowOnError();
     return drive.AppendTo(string.Empty);
 }
开发者ID:toroso,项目名称:fs4net,代码行数:7,代码来源:CanonicalPathBuilder.cs


示例4: btnOK_Click

    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator()
            .NotEmpty(txtTimeZoneName.Text, rfvName.ErrorMessage)
            .NotEmpty(txtTimeZoneDisplayName.Text, rfvDisplayName.ErrorMessage)
            .NotEmpty(txtTimeZoneGMT.Text, rfvGMT.ErrorMessage)
            .IsCodeName(txtTimeZoneName.Text, GetString("general.invalidcodename"))
            .IsDouble(txtTimeZoneGMT.Text, rvGMTDouble.ErrorMessage)
            .Result;
        if (chkTimeZoneDaylight.Checked)
        {
            if ((!startRuleEditor.IsValid()) || (!endRuleEditor.IsValid()))
            {
                errorMessage = GetString("TimeZ.RuleEditor.NotValid");
            }
        }

        if (errorMessage == "")
        {
            // timeZoneName must to be unique
            TimeZoneInfo timeZoneObj = TimeZoneInfoProvider.GetTimeZoneInfo(txtTimeZoneName.Text.Trim());

            // if timeZoneName value is unique
            if ((timeZoneObj == null) || (timeZoneObj.TimeZoneID == zoneid))
            {
                // if timeZoneName value is unique -> determine whether it is update or insert
                if ((timeZoneObj == null))
                {
                    // get TimeZoneInfo object by primary key
                    timeZoneObj = TimeZoneInfoProvider.GetTimeZoneInfo(zoneid);
                    if (timeZoneObj == null)
                    {
                        // create new item -> insert
                        timeZoneObj = new TimeZoneInfo();
                    }
                }

                timeZoneObj.TimeZoneName = txtTimeZoneName.Text.Trim();
                timeZoneObj.TimeZoneDaylight = chkTimeZoneDaylight.Checked;
                timeZoneObj.TimeZoneDisplayName = txtTimeZoneDisplayName.Text.Trim();
                timeZoneObj.TimeZoneRuleStartIn = ValidationHelper.GetDateTime(TimeZoneInfoProvider.CreateRuleDateTime(startRuleEditor.Rule), DateTime.Now);
                timeZoneObj.TimeZoneRuleEndIn = ValidationHelper.GetDateTime(TimeZoneInfoProvider.CreateRuleDateTime(endRuleEditor.Rule), DateTime.Now);
                timeZoneObj.TimeZoneRuleStartRule = startRuleEditor.Rule;
                timeZoneObj.TimeZoneRuleEndRule = endRuleEditor.Rule;
                timeZoneObj.TimeZoneGMT = Convert.ToDouble(txtTimeZoneGMT.Text.Trim());

                TimeZoneInfoProvider.SetTimeZoneInfo(timeZoneObj);

                URLHelper.Redirect("TimeZone_Edit.aspx?zoneid=" + Convert.ToString(timeZoneObj.TimeZoneID) + "&saved=1");
            }
            else
            {
                ShowError(GetString("TimeZ.Edit.TimeZoneNameExists"));
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:63,代码来源:TimeZone_Edit.aspx.cs


示例5: CanonicalPathBuilder

 public CanonicalPathBuilder(string fullPath)
 {
     _fullPath = fullPath;
     ThrowHelper.ThrowIfNull(fullPath, "fullPath");
     if (_fullPath == null) throw new InvalidPathException("The path is empty.");
     _validator = new Validator(_fullPath);
 }
开发者ID:toroso,项目名称:fs4net,代码行数:7,代码来源:CanonicalPathBuilder.cs


示例6: ButtonOK_Click

    /// <summary>
    /// Saves new workflow's data and redirects to Workflow_Edit.aspx.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Event arguments</param>
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        // finds whether required fields are not empty
        string result = new Validator().NotEmpty(txtWorkflowDisplayName.Text, GetString("Development-Workflow_New.RequiresDisplayName")).NotEmpty(txtWorkflowCodeName.Text, GetString("Development-Workflow_New.RequiresCodeName"))
            .IsCodeName(txtWorkflowCodeName.Text, GetString("general.invalidcodename"))
            .Result;

        if (result == "")
        {
            WorkflowInfo wi = WorkflowInfoProvider.GetWorkflowInfo(txtWorkflowCodeName.Text);
            if (wi == null)
            {
                int workflowId = SaveNewWorkflow();

                if (workflowId > 0)
                {
                    WorkflowStepInfoProvider.CreateDefaultWorkflowSteps(workflowId);
                    URLHelper.Redirect("Workflow_Edit.aspx?workflowid=" + workflowId + "&saved=1");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("Development-Workflow_New.WorkflowExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = result;
        }
    }
开发者ID:KuduApps,项目名称:Kentico,代码行数:37,代码来源:Workflow_New.aspx.cs


示例7: Validate_Should_Return_Error_When_Referenced_Collection_Of_Objects_Have_Errors

        public void Validate_Should_Return_Error_When_Referenced_Collection_Of_Objects_Have_Errors()
        {
            // Arrange
            var testClass =
                new TestClassWithCollectionOfReferencesToAnotherClass
                {
                    TestProperty =
                        new[]
                        {
                            new TestClass { TestProperty1 = "ABC", TestProperty2 = null },
                            new TestClass { TestProperty1 = "ABC", TestProperty2 = "ABC"},
                            new TestClass { TestProperty1 = null, TestProperty2 = "ABC"}
                        }
                };

            var validator = new Validator();

            // Act
            var errors = validator.Validate(testClass);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(testClass, errors.Object);
            Assert.AreEqual(2, errors.Errors.Length);

            Assert.AreEqual("TestProperty2", errors.Errors[0].Key);
            Assert.AreEqual("Error2", errors.Errors[0].Message);
            Assert.AreEqual("TestProperty1", errors.Errors[1].Key);
            Assert.AreEqual("Error1", errors.Errors[1].Message);
        }
开发者ID:dilterporto,项目名称:Validator,代码行数:30,代码来源:ValidatorTests.cs


示例8: ButtonOK_Click

    /// <summary>
    /// Saves data of edited workflow from TextBoxes into DB.
    /// </summary>
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        // finds whether required fields are not empty
        string result = new Validator().NotEmpty(TextBoxWorkflowDisplayName.Text, GetString("Development-Workflow_New.RequiresDisplayName"))
            .NotEmpty(txtCodeName.Text, GetString("Development-Workflow_New.RequiresCodeName"))
            .IsCodeName(txtCodeName.Text, GetString("general.invalidcodename"))
            .Result;

        if (result == "")
        {
            if (currentWorkflow != null)
            {
                // Codename must be unique
                WorkflowInfo wiCodename = WorkflowInfoProvider.GetWorkflowInfo(txtCodeName.Text);
                if ((wiCodename == null) || (wiCodename.WorkflowID == currentWorkflow.WorkflowID))
                {
                    if (currentWorkflow.WorkflowDisplayName != TextBoxWorkflowDisplayName.Text)
                    {
                        // Refresh header
                        ScriptHelper.RefreshTabHeader(Page, null);
                    }

                    currentWorkflow.WorkflowDisplayName = TextBoxWorkflowDisplayName.Text;
                    currentWorkflow.WorkflowName = txtCodeName.Text;
                    currentWorkflow.WorkflowAutoPublishChanges = chkAutoPublish.Checked;

                    // Inherited from global settings
                    if (radSiteSettings.Checked)
                    {
                        currentWorkflow.WorkflowUseCheckinCheckout = null;
                    }
                    else
                    {
                        currentWorkflow.WorkflowUseCheckinCheckout = radYes.Checked;
                    }

                    // Save workflow info
                    WorkflowInfoProvider.SetWorkflowInfo(currentWorkflow);

                    lblInfo.Visible = true;
                    lblInfo.Text = GetString("General.ChangesSaved");
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text = GetString("Development-Workflow_New.WorkflowExists");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("Development-Workflow_General.WorkflowDoesNotExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = result;
        }
    }
开发者ID:KuduApps,项目名称:Kentico,代码行数:63,代码来源:Workflow_General.aspx.cs


示例9: ButtonOK_Click

    /// <summary>
    /// Saves new relationship name's data and redirects to RelationshipName_Edit.aspx.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Event arguments</param>
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        // finds whether required fields are not empty
        string result = new Validator().NotEmpty(txtRelationshipNameDisplayName.Text, GetString("General.RequiresDisplayName")).NotEmpty(txtRelationshipNameCodeName.Text, GetString("General.RequiresCodeName"))
            .IsCodeName(txtRelationshipNameCodeName.Text, GetString("general.invalidcodename"))
            .Result;

        if (result == string.Empty)
        {
            RelationshipNameInfo rni = RelationshipNameInfoProvider.GetRelationshipNameInfo(txtRelationshipNameCodeName.Text);
            if (rni == null)
            {
                int relationshipNameId = SaveNewRelationshipName();

                if (relationshipNameId > 0)
                {
                    URLHelper.Redirect("RelationshipName_Edit.aspx?relationshipnameid=" + relationshipNameId + "&saved=1");
                }
            }
            else
            {
                ShowError(GetString("RelationshipNames.RelationshipNameAlreadyExists"));
            }
        }
        else
        {
            ShowError(result);
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:34,代码来源:RelationshipName_New.aspx.cs


示例10: Save

    private void Save()
    {
        string validationResult = new Validator()
            .NotEmpty(txtServerName.Text, rfvServerName.ErrorMessage)
            .Result;

        if (!string.IsNullOrEmpty(validationResult))
        {
            ShowError(validationResult);
            return;
        }

        try
        {
            SMTPServerPriorityEnum priority = (SMTPServerPriorityEnum)Enum.Parse(typeof(SMTPServerPriorityEnum), ddlPriorities.SelectedValue);

            SMTPServerInfo smtpServer =
                SMTPServerInfoProvider.CreateSMTPServer(txtServerName.Text, txtUserName.Text, txtPassword.Text, chkUseSSL.Checked, priority);

            if (chkAssign.Checked && currentSite != null)
            {
                SMTPServerSiteInfoProvider.AddSMTPServerToSite(smtpServer.ServerID, currentSite.SiteID);
            }

            URLHelper.Redirect(string.Format("Frameset.aspx?smtpserverid={0}&saved=1", smtpServer.ServerID));
        }
        catch (Exception e)
        {
            ShowError(e.Message);
            return;
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:32,代码来源:New.aspx.cs


示例11: btnOK_Click

    /// <summary>
    /// Handles btnOK's OnClick event - Update resource info.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check if input is valid
        string cultureCode = txtUICultureCode.Text.Trim();
        string result = new Validator()
            .NotEmpty(txtUICultureName.Text, rfvUICultureName.ErrorMessage)
            .NotEmpty(cultureCode, rfvUICultureCode.ErrorMessage)
            .Result;

        // Check if requested culture exists
        try
        {
            CultureInfo obj = new CultureInfo(cultureCode);
        }
        catch
        {
            result = GetString("UICulture.ErrorNoGlobalCulture");
        }

        if (!string.IsNullOrEmpty(result))
        {
            ShowError(result);
        }
        else
        {
            SaveUICulture(cultureCode);
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:31,代码来源:Tab_General.aspx.cs


示例12: nameElem_Click

    void nameElem_Click(object sender, EventArgs e)
    {
        // Code name validation
        string err = new Validator().IsIdentificator(nameElem.CodeName, GetString("general.erroridentificatorformat")).Result;
        if (err != String.Empty)
        {
            lblError.Visible = true;
            lblError.Text = err;
            return;
        }

        // Checking for duplicate items
        DataSet ds = AlternativeFormInfoProvider.GetAlternativeForms("FormName='" + SqlHelperClass.GetSafeQueryString(nameElem.CodeName, false) +
            "' AND FormClassID=" + classId, null);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            lblError.Visible = true;
            lblError.Text = GetString("general.codenameexists");
            return;
        }

        // Create new info object
        AlternativeFormInfo afi = new AlternativeFormInfo();
        afi.FormID = 0;
        afi.FormGUID = Guid.NewGuid();
        afi.FormClassID = classId;
        afi.FormName = nameElem.CodeName;
        afi.FormDisplayName = nameElem.DisplayName;

        AlternativeFormInfoProvider.SetAlternativeFormInfo(afi);

        URLHelper.Redirect("AlternativeForms_Frameset.aspx?classid=" + classId + "&altformid=" + afi.FormID + "&saved=1");
    }
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:34,代码来源:AlternativeForms_New.aspx.cs


示例13: Start

    public Point2D gazeCoords; //average coordinates from tet gaze data

	//init
	void Start () {
        //validate gaze data
        gazeValidator = new Validator(30);

        //listen for gaze events
        GazeManager.Instance.AddGazeListener(this);
	} //end function
开发者ID:Ar2rZ,项目名称:tetbeams,代码行数:10,代码来源:GazeDataManager.cs


示例14: Check_all_possible_errors_and_get_a_list_of_custom_exceptions

        public void Check_all_possible_errors_and_get_a_list_of_custom_exceptions()
        {
            var list = new Validator().CheckThat(() => _integerToCheck)
                .IsEqualTo<ArgumentException>(17,null)
                .IsEqualTo<ArgumentException>(_integerToCheck, null)
                .IsLessThan<ArgumentException>(17, null)
                .IsLessThan<ArgumentException>(12, null)
                .IsMoreThan<ArgumentException>(12, null)
                .IsMoreThan<ArgumentException>(17, null)
                .IsLessOrEqualTo<ArgumentException>(13, null)
                .IsLessOrEqualTo<ArgumentException>(14, null)
                .IsLessOrEqualTo<ArgumentException>(17, null)
                .IsMoreOrEqualTo<ArgumentException>(13, null)
                .IsMoreOrEqualTo<ArgumentException>(14, null)
                .IsMoreOrEqualTo<ArgumentException>(17, null)
                .IsBetween<ArgumentException>(3, 9,null)
                .IsBetween<ArgumentException>(8, 17,null)
                .IsBetween<ArgumentException>(15, 18,null)
                .List();

            Assert.That(list.ErrorsCollection.First().Value.Count, Is.EqualTo(7));
            foreach (var exception in list.ErrorsCollection.First().Value)
            {
                Assert.IsInstanceOfType(typeof(ArgumentException),exception);
            }
        }
开发者ID:GunioRobot,项目名称:DynamicProg,代码行数:26,代码来源:CheckThat_Int_Test.cs


示例15: btnOK_Click

    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check valid input
        string errMsg = new Validator().
            NotEmpty(this.txtName.Text, GetString("img.errors.filename")).
            IsFolderName(this.txtName.Text, GetString("img.errors.filename")).
            Result;

        // Prepare the path
        string path = filePath;
        if (!newFile)
        {
            path = Path.GetDirectoryName(path);
        }
        path += "/" + txtName.Text + extension;

        // Check the file name for existence
        if (!this.txtName.Text.Equals(fileName, StringComparison.InvariantCultureIgnoreCase))
        {
            if (File.Exists(path))
            {
                errMsg = GetString("general.fileexists");
            }
        }

        if (!String.IsNullOrEmpty(errMsg))
        {
            this.lblError.Text = errMsg;
            this.lblError.Visible = true;
        }
        else
        {
            try
            {
                if (!newFile && !path.Equals(filePath, StringComparison.InvariantCultureIgnoreCase))
                {
                    // Move the file to the new location
                    File.WriteAllText(filePath, this.txtContent.Text);
                    File.Move(filePath, path);
                }
                else
                {
                    // Create the file or write into it
                    File.WriteAllText(path, this.txtContent.Text);
                }

                string script = "wopener.SetRefreshAction(); window.close()";

                this.ltlScript.Text = ScriptHelper.GetScript(script);
            }
            catch (Exception ex)
            {
                this.lblError.Text = ex.Message;
                this.lblError.Visible = true;

                // Log the exception
                EventLogProvider.LogException("FileSystemSelector", "SAVEFILE", ex);
            }
        }
    }
开发者ID:KuduApps,项目名称:Kentico,代码行数:60,代码来源:EditTextFile.aspx.cs


示例16: btnSend_Click

    /// <summary>
    /// On btnSend click.
    /// </summary>
    protected void btnSend_Click(object sender, EventArgs e)
    {
        txtFrom.Text = txtFrom.Text.Trim();
        txtTo.Text = txtTo.Text.Trim();

        string result = new Validator()
            .NotEmpty(txtFrom.Text, GetString("System_Email.EmptyEmail"))
            .NotEmpty(txtTo.Text, GetString("System_Email.EmptyEmail"))
            .Result;

        if (result != string.Empty)
        {
            ShowError(result);
            return;
        }

        // Validate e-mail addresses
        if (!(ValidationHelper.IsEmail(txtFrom.Text) && ValidationHelper.IsEmail(txtTo.Text)))
        {
            ShowError(GetString("System_Email.ErrorEmail"));
            return;
        }

        // Send the e-mail
        try
        {
            SendEmail();
            ShowConfirmation(GetString("System_Email.EmailSent"));
        }
        catch (Exception ex)
        {
            string message = EventLogProvider.GetExceptionLogMessage(ex);
            ShowError(ex.Message, message, null);
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:38,代码来源:SendEmail.aspx.cs


示例17: TestValidator

    public void TestValidator()
    {
      var validator = new Validator();

      Assert.AreEqual("", validator.Validate());
      Assert.AreEqual("", validator.Error);

      validator.AddValidationRule(() => TestInt).Condition(() => TestInt <= 0).Message("Test int validation message");
      validator.Validate();
      Assert.IsFalse(string.IsNullOrWhiteSpace(validator.Validate()));
      Assert.AreEqual("Test int validation message", validator.Error);

      validator.AddValidationRule(() => TestObject).Condition(() => TestObject == null).Message("Test object validation message");
      validator.Validate();
      Assert.IsTrue(validator.Error.Contains("Test int validation message"));
      Assert.IsTrue(validator.Error.Contains("Test object validation message"));

      TestInt = 100;
      validator.Validate();
      Assert.AreEqual("Test object validation message", validator.Error);
      Assert.AreEqual("Test object validation message", validator["TestObject"]);
      Assert.IsTrue(string.IsNullOrWhiteSpace(validator["TestInt"]));

      TestObject = new object();
      Assert.AreEqual("", validator.Validate());
      Assert.AreEqual("", validator.Error);

      TestObject = null;
      validator.Validate();
      Assert.AreEqual("Test object validation message", validator.Error);
      validator.RemoveValidationRule(() => TestObject);
      validator.Validate();
      Assert.IsTrue(string.IsNullOrWhiteSpace(validator.Error));
    }
开发者ID:dingjimmy,项目名称:Caliburn.Micro.FluentValidation,代码行数:34,代码来源:ValidatorTest.cs


示例18: Should_be_able_to_create_a_validator_for_a_class

 public void Should_be_able_to_create_a_validator_for_a_class()
 {
     _validator = Validator.New<Order>(x =>
         {
             // No Conditions Specified
         });
 }
开发者ID:daffers,项目名称:Magnum,代码行数:7,代码来源:Validation_Tests.cs


示例19: btnOK_Click

    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (customerObj == null)
        {
            return;
        }

        if (!ECommerceContext.IsUserAuthorizedToModifyCustomer())
        {
            RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers");
        }

        if (customerId != 0)
        {
            string errorMessage = new Validator().NotEmpty(txtAddressLine1.Text, "Customer_Edit_Address_Edit.rqvLine")
                                                 .NotEmpty(txtAddressCity.Text, "Customer_Edit_Address_Edit.rqvCity")
                                                 .NotEmpty(txtAddressZip.Text, "Customer_Edit_Address_Edit.rqvZipCode")
                                                 .NotEmpty(txtPersonalName.Text, "Customer_Edit_Address_Edit.rqvPersonalName").Result;

            // Check country presence
            if (errorMessage == "" && (ucCountrySelector.CountryID <= 0))
            {
                errorMessage = GetString("countryselector.selectedcountryerr");
            }

            if (errorMessage == "")
            {
                // Get object
                AddressInfo addressObj = AddressInfoProvider.GetAddressInfo(addressId);
                if (addressObj == null)
                {
                    addressObj = new AddressInfo();
                }

                addressObj.AddressIsBilling = chkAddressIsBilling.Checked;
                addressObj.AddressIsShipping = chkAddressIsShipping.Checked;
                addressObj.AddressZip = txtAddressZip.Text.Trim();
                addressObj.AddressPhone = txtAddressDeliveryPhone.Text.Trim();
                addressObj.AddressPersonalName = txtPersonalName.Text.Trim();
                addressObj.AddressLine1 = txtAddressLine1.Text.Trim();
                addressObj.AddressEnabled = chkAddressEnabled.Checked;
                addressObj.AddressLine2 = txtAddressLine2.Text.Trim();
                addressObj.AddressCity = txtAddressCity.Text.Trim();
                addressObj.AddressCountryID = ucCountrySelector.CountryID;
                addressObj.AddressStateID = ucCountrySelector.StateID;
                addressObj.AddressIsCompany = chkAddressIsCompany.Checked;
                addressObj.AddressName = AddressInfoProvider.GetAddressName(addressObj);
                addressObj.AddressCustomerID = customerId;

                AddressInfoProvider.SetAddressInfo(addressObj);

                URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerId + "&addressId=" + Convert.ToString(addressObj.AddressID) + "&saved=1");
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = errorMessage;
            }
        }
    }
开发者ID:KuduApps,项目名称:Kentico,代码行数:63,代码来源:Customer_Edit_Address_Edit.aspx.cs


示例20: ShouldCopyToModelState

		public void ShouldCopyToModelState()
		{
			var modelstate = new ModelStateDictionary();

			const string property = "";

			var validator = new Validator
            {
            	() => property.Label("Property 1").IsRequired(),
            	() => property.Label("Property 2").IsRequired(),
            	() => property.Label("Property 3").IsRequired()
            };

			try
			{
				validator.Validate();
			}
			catch (ValidationException ex)
			{
				ex.CopyToModelState(modelstate, "foo");
			}

			modelstate.Count.ShouldEqual(3);
			modelstate["foo.Property 1"].ShouldNotBeNull();
			modelstate["foo.Property 2"].ShouldNotBeNull();
			modelstate["foo.Property 3"].ShouldNotBeNull();

		}
开发者ID:bertusmagnus,项目名称:Sutekishop,代码行数:28,代码来源:ValidationExtensionsTests.cs



注:本文中的Validator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ValidatorEngine类代码示例发布时间:2022-05-24
下一篇:
C# ValidationType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap