예제 #1
0
 private void txtPublisherName_Validating(object sender, CancelEventArgs e)
 {
     if (ValidateInput.IsEmpty(txtPublisherName.Text, out errMsg))
     {
         CancelValidatedEvent(grpPublisher, lblPublisherNameError, e);
     }
 }
예제 #2
0
 private void txtAddress_Validating(object sender, CancelEventArgs e)
 {
     if (ValidateInput.IsEmpty(txtAddress.Text, out errMsg))
     {
         CancelValidatedEvent(grpAddress, lblAddressError, e);
     }
 }
예제 #3
0
 private void txtNewPassword_Validating(object sender, CancelEventArgs e)
 {
     if (!ValidateInput.ValidNoneSpecialChar(txtNewPassword.Text, out errMsg))
     {
         CancelValidatedEvent(grpNewPassword, lblNewPasswordError, e);
     }
 }
예제 #4
0
        public HttpResponseMessage Create(string apiKey, string type, string value, string format = "png", bool returnAsBase64 = false)
        {
            // Validate the api key
            ValidateApi validateApi = new ValidateApi();
            Validation validateApiKey = validateApi.ValidateApiKey(apiKey);

            // Api key is invalid.
            if (!validateApiKey.IsValid)
            {
                return BuildErrorResponse(validateApiKey);    
            }

            // Validate the values first
            ValidateInput validation = new ValidateInput();
            Validation validationInput = validation.ValidateBarcodeValue(type, value);
            
            // Result is Valid
            if (validationInput.IsValid)
            {
                return CreateBarcode(type, value, format, returnAsBase64);
            }

            // Result is not valid
            return BuildErrorResponse(validationInput);
        }
예제 #5
0
 private void txtStaffName_Validating(object sender, CancelEventArgs e)
 {
     if (!ValidateInput.ValidOnlyLetter(txtStaffName.Text, out errMsg))
     {
         CancelValidatedEvent(grpStaffName, lblStaffNameError, e);
     }
 }
예제 #6
0
        public HttpResponseMessage Create(string apiKey, string type, string value, string format = "png", bool returnAsBase64 = false)
        {
            // Validate the api key
            ValidateApi validateApi    = new ValidateApi();
            Validation  validateApiKey = validateApi.ValidateApiKey(apiKey);

            // Api key is invalid.
            if (!validateApiKey.IsValid)
            {
                return(BuildErrorResponse(validateApiKey));
            }

            // Validate the values first
            ValidateInput validation      = new ValidateInput();
            Validation    validationInput = validation.ValidateBarcodeValue(type, value);

            // Result is Valid
            if (validationInput.IsValid)
            {
                return(CreateBarcode(type, value, format, returnAsBase64));
            }

            // Result is not valid
            return(BuildErrorResponse(validationInput));
        }
예제 #7
0
 private void txtPhoneNumber_Validating(object sender, CancelEventArgs e)
 {
     if (!ValidateInput.ValidVietnamesePhone(txtPhoneNumber.Text, out errMsg))
     {
         CancelValidatedEvent(grpPhoneNumber, lblPhoneNumberWarning, e);
     }
 }
예제 #8
0
        public JsonResult addEmail(string pEmail)
        {
            V308CMSEntities mEntities       = new V308CMSEntities();
            EmailRepository emailRepository = new EmailRepository(mEntities);

            try
            {
                if (ValidateInput.IsValidEmailAddress(pEmail))
                {
                    VEmail mVEmail = new VEmail()
                    {
                        CreatedDate = DateTime.Now, State = true, Type = 1, Value = pEmail
                    };
                    mEntities.AddToVEmail(mVEmail);
                    mEntities.SaveChanges();
                    return(Json(new { code = 1, message = "Email đã được thêm vào hệ thống." }));
                }
                else
                {
                    return(Json(new { code = 0, message = "Email bạn nhập không chính xác." }));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("error :", ex);
                return(Json(new { code = 0, message = "Có lỗi xảy ra. Vui lòng thử lại." }));
            }
            finally
            {
                mEntities.Dispose();
                emailRepository.Dispose();
            }
        }
        public void TestValidateAndConvertToDoubleNotOK2()
        {
            string teststring = "-100";

            Assert.AreNotEqual(ValidateInput.ValidateAndConvertToDouble(teststring), new Tuple <bool, double>(true, 100));
            Assert.AreEqual(ValidateInput.ValidateAndConvertToDouble(teststring), new Tuple <bool, double>(false, Double.MinValue));
        }
예제 #10
0
        public void Test(bool wholeWords, string input, bool isAllowed)
        {
            var processor = new ValidateInput
            {
                WholeWordsOnly = wholeWords
            };

            var args = new ProfanityFilterArgs
            {
                Input    = input,
                WordList = new List <string> {
                    "x", "y"
                }
            };

            processor.Process(args);

            if (isAllowed)
            {
                Assert.That(args.Valid, Is.True);
            }
            else
            {
                Assert.That(args.Valid, Is.False);
            }
        }
예제 #11
0
        public void TestValidateAndConvertToIntNotOK2()
        {
            string teststring = "-100";

            Assert.AreNotEqual(ValidateInput.ValidateAndConvertToInt(teststring), new Tuple <bool, int>(true, 100));
            Assert.AreEqual(ValidateInput.ValidateAndConvertToInt(teststring), new Tuple <bool, int>(false, 0));
        }
예제 #12
0
 private void txtEmail_Validating(object sender, CancelEventArgs e)
 {
     if (!ValidateInput.ValidEmail(txtEmail.Text, out errMsg))
     {
         CancelValidatedEvent(grpEmail, lblEmailError, e);
     }
 }
예제 #13
0
 public PromptForm()
 {
     InitializeComponent();
     AutoSize     = true;
     FormClosing += delegate(object sender, FormClosingEventArgs args)
     {
         bool valid = true;
         if (ValidateInput != null)
         {
             foreach (var d in ValidateInput.GetInvocationList())
             {
                 valid = (bool)d.DynamicInvoke();
                 if (!valid)
                 {
                     break;
                 }
             }
         }
         bool cancel = DialogResult != DialogResult.Cancel && !valid;
         if (cancel)
         {
             args.Cancel = true;
             SystemSounds.Beep.Play();
         }
     };
     MinimumSize = new Size(400, 150);
 }
예제 #14
0
 private void txtAccountName_Validating(object sender, CancelEventArgs e)
 {
     if (!ValidateInput.ValidNoneSpecialChar(txtAccountName.Text, out errMsg))
     {
         CancelValidatedEvent(grpAccountName, lblAccountNameError, e);
     }
 }
예제 #15
0
 private void txtAvailable_Validating(object sender, CancelEventArgs e)
 {
     if (ValidateInput.IsEmpty(txtAvailable.Text, out errMsg))
     {
         CancelValidatedEvent(grpAvailable, lblAvailableWarning, e);
     }
 }
예제 #16
0
        public void TestPathStringRight()
        {
            string path        = @"\Desktop";
            string filename    = "test";
            string returnvalue = @"\Desktop\test";

            Assert.AreEqual(ValidateInput.PathString(filename, path), returnvalue);
        }
예제 #17
0
 public void TestFilenameExistsExist()
 {
     CreateProject.CreateFolder(@"Model\exist");
     LoadSave.ZipFolderRenameToDCIP(@"Model\exist");
     Assert.True(ValidateInput.FileNameExists("exist", @"Model\"));
     LoadSave.DeleteOriginalFolder(@"Model\exist");
     System.IO.File.Delete(@"Model\exist.dcip");
 }
        private void BTN_DialogCourseAdd_Click(object sender, EventArgs e)
        {
            bool   pass = true;
            string msg  = "";
            int    i    = 1;

            if (!ValidateInput.IsValid(TXT_DialogCourseCode))
            {
                pass = false;
                msg += i + ". Course Code must not be blank\n";
                i++;
            }
            if (!ValidateInput.IsValid(TXT_DialogCourseName))
            {
                pass = false;
                msg += i + ". Course Name must not be blank\n";
                i++;
            }

            // Send tmpCourseFee to function and not TXT_DialogCourseFee.Text
            decimal tmpCourseFee;

            if (!ValidateInput.IsValid(TXT_DialogCourseFee, true, out tmpCourseFee))
            {
                pass = false;
                msg += i + ". Fee Must be a valid amount\n";
                i++;
            }
            if (!pass)
            {
                msg += "\nRequired fields must be valid.";
                MessageBox.Show(null, msg, "Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.None;
                return;
            }
            Course course = new Course()
            {
                CourseCode = TXT_DialogCourseCode.Text,
                Name       = TXT_DialogCourseName.Text,
                Fee        = tmpCourseFee
            };

            // If validation successful
            if (editUpdate)
            {
                if (cmd.UpdateCourse(course))
                {
                    mainForm.GetView("Colleges");
                }
            }
            else
            {
                if (cmd.AddCourse(course))
                {
                    mainForm.GetView("Colleges");
                }
            }
        }
        public void ValidatePlayAgainWrongInputTest()
        {
            string        invalidInput = "K";
            bool          expected     = false;
            ValidateInput validInput   = new ValidateInput();
            bool          actual       = validInput.ValidateYesNoInput(invalidInput);

            Assert.Equal(expected, actual);
        }
예제 #20
0
 /// <summary>
 /// Validates the provided OAuth JWT token or Authorization header. Documentation: https://github.com/CommunityHiQ/Frends.Community.OAuth/
 /// </summary>
 /// <param name="input">Parameters for the token validation</param>
 /// <returns>string</returns>
 public static async Task <ParseResult> Validate(ValidateInput input, CancellationToken cancellationToken)
 {
     return(await ParseToken(input, new ParseOptions
     {
         SkipIssuerValidation = false,
         SkipAudienceValidation = false,
         SkipLifetimeValidation = false
     }, cancellationToken));
 }
        public void InputToUpperTest()
        {
            string        input      = "All will Return Upper Case";
            string        expected   = "ALL WILL RETURN UPPER CASE";
            ValidateInput validInput = new ValidateInput();
            string        actual     = validInput.InputToUpper(input);

            Assert.Equal(expected, actual);
        }
        public void ValidatePlayAgainAccurateInputTest()
        {
            string        invalidInput = "N";
            bool          expected     = true;
            ValidateInput validInput   = new ValidateInput();
            bool          actual       = validInput.ValidateYesNoInput(invalidInput);

            Assert.Equal(expected, actual);
        }
예제 #23
0
        private void FullExecBtn_Click(object sender, EventArgs e)
        {
            //while (stopwatch.Elapsed < TimeSpan.FromSeconds(5))
            //{
            //    // Execute your loop here...
            //}

            if (IsAssembled)
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                while (!IsDone)
                {
                    SingleStepBtn.PerformClick();

                    if (stopwatch.Elapsed > TimeSpan.FromSeconds(20))
                    {
                        UpdateErrorLog(ValidateInput.InfiniteLoopMsg());
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("Please resolve all errors or warning before simulation.", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }



            //try
            //{
            //    if (IsAssembled)
            //    {
            //        MainCTRL.rxSG = MainCTRL.InitializeRegister(RegisterTab.ConvertDGtoDT("Register"));
            //        foreach (var code in MainCTRL.txSG)
            //        {
            //            // Simulator   MainCTRL.DataSGDT, MainCTRL.dxSG
            //            MainCTRL.rxSG = OperationController.ExecuteOperation(code, MainCTRL.DataSGDT, MainCTRL.rxSG);
            //            RegisterTab.SetTemplateDT(MainCTRL.GenerateRegisterSGDT());

            //            // Cache
            //            SimulateCache(code);
            //        }
            //        //cacheHitRateLbl.Text = CacheController.CacheHitRate();
            //        UpdateErrorLog(ValidateInput.ExecuteMsg());
            //    } else
            //    {
            //        MessageBox.Show("Please resolve all errors or warning before simulation.", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }
        // VALIDATION EVENTS
        private string InitValidation(string blockSize, string cacheSize, string sourceCode, bool IsMRU)
        {
            string err = string.Empty;

            err += ValidateInput.IsBlockCacheSize(blockSize, "Block");
            err += ValidateInput.IsBlockCacheSize(cacheSize, "Cache");
            err += ValidateInput.HasCode(sourceCode);
            //err += ValidateInput.IsReplaceAlgoSet(IsMRU);
            return(err);
        }
        public void ValidateUserQuestionEntryCorrectInputTest()
        {
            string        input      = "2";
            bool          isInt      = true;
            int           index      = 0;
            ValidateInput validInput = new ValidateInput();

            validInput.ValidateUserQuestionEntry(input, out isInt, out index);
            Assert.True(isInt);
        }
        public void ValidateUserQuestionEntryBadInputTest()
        {
            string        input      = "onethirty";
            bool          isInt      = false;
            int           index      = 0;
            ValidateInput validInput = new ValidateInput();

            validInput.ValidateUserQuestionEntry(input, out isInt, out index);
            Assert.False(isInt);
        }
예제 #27
0
        /// <summary>
        /// Gets called when a project needs to be created.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="destination"></param>
        /// <returns>bool: went well/bad</returns>
        public static void Create(string filename, string destination)
        {
            string pathstring = ValidateInput.PathString(filename, destination);

            CreateFolder(pathstring);

            DiffusionCurves.Auxillary.LoadSave.ZipFolderRenameToDCIP(pathstring);

            DiffusionCurves.Auxillary.LoadSave.DeleteOriginalFolder(pathstring);
        }
예제 #28
0
 private void txtReaderName_Validating(object sender, CancelEventArgs e)
 {
     if (ValidateInput.IsEmpty(txtReaderName.Text, out errMsg))
     {
         CancelValidatedEvent(grpReaderName, lblReaderNameError, e);
     }
     if (!ValidateInput.ValidOnlyLetter(txtReaderName.Text, out errMsg))
     {
         CancelValidatedEvent(grpReaderName, lblReaderNameError, e);
     }
 }
예제 #29
0
        public void TestDecimalValidationToFail()
        {
            //Arrange
            string testDecimal = "z12.38";
            //Act
            bool passed = ValidateInput.IsValid(testDecimal, out decimal number);

            //Assert
            Assert.IsFalse(passed);
            //Assert.AreEqual(12.38m, number);
        }
예제 #30
0
        public void TestDecimalValidationOutputOnFailure()
        {
            //Arrange
            string testDecimal = "z12.38";
            //Act
            bool passed = ValidateInput.IsValid(testDecimal, out decimal number);

            //Assert
            //Assert.IsTrue(passed);
            Assert.AreEqual(0, number);
        }
예제 #31
0
 private void txtGenreName_Validating(object sender, CancelEventArgs e)
 {
     if (ValidateInput.IsEmpty(txtGenreName.Text, out errMsg))
     {
         errMsg = "Trường này không được trống";
         CancelValidatedEvent(lblGenreNameError, e);
     }
     else if (!ValidateInput.ValidOnlyLetter(txtGenreName.Text, out errMsg))
     {
         CancelValidatedEvent(lblGenreNameError, e);
     }
 }
예제 #32
0
        public HttpResponseMessage CreateBatch(ImageBatch imageBatch)
        {
            // Our response object
            ImageBatchResponse batchResult = new ImageBatchResponse();

            // Validate the api key
            ValidateApi validateApi = new ValidateApi();
            Validation validateApiKey = validateApi.ValidateApiKey(imageBatch.ApiKey);

            // Api key is invalid.
            if (!validateApiKey.IsValid)
            {
                return BuildErrorResponse(validateApiKey);
            }

            // Loop through the values
            List<ImageResponse> imageList = new List<ImageResponse>();
            foreach (ImageDetails detail in imageBatch.ImageDetails)
            {
                // Validate the values first
                ValidateInput validation = new ValidateInput();
                Validation validationInput = validation.ValidateBarcodeValue(detail.Type, detail.Value);

                // Result is Valid
                ImageResponse imageResponse = new ImageResponse();
                if (validationInput.IsValid)
                {
                    imageResponse.ImageUrl = string.Format(
                        "http://www.codegenerate.me/Code/Barcode?type={0}&value={1}", detail.Type, detail.Value);
                    imageResponse.Result = "Success";
                    batchResult.SuccessfulCount++;
                }
                else
                {
                    imageResponse.Result = validationInput.ErrorMessage;
                }

                imageList.Add(imageResponse);
            }

            // Add the images
            batchResult.Images = imageList.ToArray();

            // Build the object to return
            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK)
                                             {Content = new StringContent(batchResult.ToJSON())};

            return result;
        }
예제 #33
0
        public ActionResult Validate(string type, string value)
        {
            ValidateInput validation = new ValidateInput();
            Validation validationResult = validation.ValidateBarcodeValue(type, value);

            return Json(validationResult, JsonRequestBehavior.AllowGet);
        }