public override bool IsValid(object value)
        {
            bool isValid;

            // Required validation will be separated
            if (value == null)
            {
                return(true);
            }

            ErrorMessage = Errors.E_FORMAT_NOT_VALID;

            if (isNegative)
            {
                isValid = AppValidator.ValidateNumber(value, AppValidations.NEGATIVE_NUM_MIN_VALUE, AppValidations.NUM_MAX_VALUE);
            }
            else
            {
                if (atLeastOne)
                {
                    isValid = AppValidator.ValidateNumber(value, AppValidations.POSITVE_NUM_MIN_VALUE_1, AppValidations.NUM_MAX_VALUE);
                }
                else
                {
                    isValid = AppValidator.ValidateNumber(value, AppValidations.POSITVE_NUM_MIN_VALUE_0, AppValidations.NUM_MAX_VALUE);
                }
            }

            return(isValid);
        }
예제 #2
0
        public MainPage()
        {
            this.InitializeComponent();

            AppValidator appVal = new AppValidator(new UWPDialog());

            appVal.Validate();
        }
        public override bool IsValid(object value)
        {
            // Required validation will be separated
            if (value == null)
            {
                return(true);
            }

            ErrorMessage = Errors.E_FORMAT_NOT_VALID;
            bool isLengthValid = AppValidator.ValidateString(value.ToString(), AppValidations.LONG_TEXT_MIN_LENGTH, AppValidations.LONG_TEXT_MAX_LENGTH);

            return(isLengthValid);
        }
        public override bool IsValid(object value)
        {
            // Required validation will be separated
            if (value == null)
            {
                return(true);
            }

            ErrorMessage = Errors.E_FORMAT_NOT_VALID;
            bool isValid = AppValidator.ValidateNumber(value, MinValue, MaxValue);

            return(isValid);
        }
예제 #5
0
        public override bool IsValid(object value)
        {
            bool isValid;

            ErrorMessage = Errors.E_USERNAME_NOT_VALID;
            isValid      = Regex.Match(value.EmptyIfNull(), @"^(^[a-zA-Z][0-9a-zA-Z.]*|)$").Success;
            if (!isValid)
            {
                return(false);
            }

            // cahnge error message here if you want
            isValid = AppValidator.ValidateString(value.EmptyIfNull(), AppValidations.NORMAL_TEXT_MIN_LENGTH, AppValidations.NORMAL_TEXT_MAX_LENGTH);

            return(isValid);
        }
        public override bool IsValid(object value)
        {
            ErrorMessage = Errors.E_FORMAT_NOT_VALID;

            // Allow null or empty and validate required in a seprated validation
            if (string.IsNullOrEmpty(value.ToString()))
            {
                return(true);
            }

            // Allow English and Arabic chars
            bool isFormatValid = Regex.Match(value.ToString(),
                                             @"^[a-zA-Z\u0621-\u064Aa][0-9a-zA-Z\u0621-\u064Aa ]+$").Success;

            bool isLengthValid = AppValidator.ValidateString(value.ToString(), AppValidations.NORMAL_TEXT_MIN_LENGTH, AppValidations.NORMAL_TEXT_MAX_LENGTH);

            return(isLengthValid && isFormatValid);
        }
        public override bool IsValid(object value)
        {
            bool isValid;

            // Required validation will be separated
            if (value == null)
            {
                return(true);
            }

            ErrorMessage = Errors.E_FORMAT_NOT_VALID;

            if (isNegative)
            {
                isValid = AppValidator.ValidateNumber(value, -100, 100);
            }
            else
            {
                isValid = AppValidator.ValidateNumber(value, 0, 100);
            }

            return(isValid);
        }
        /**
         * Validate Login fields for valid entries and against database entries
         * and call the MDI MAIN Screen.
         */
        private void login()
        {
            //Create an instance of application validator
            AppValidator appValidatorObj = AppValidator.getValidatorInstance();

            //Check if Username field is empty
            if (txtUsername.Text == string.Empty)
            {
                txtFieldFocus(txtUsername);
                return;
            }

            //Get value of username and password
            String username = txtUsername.Text.Trim();

            //Validate Username for alphanumeric characters

            /*if (appValidatorObj.isValidField(username, 7))
             * {
             *  txtFieldFocus(txtUsername);
             * }
             * else
             * {
             *  lblStatus.Text = "1. Can contain digit or alphanumeric characters" + "\n" +
             *                   "2. Length at least 3 characters and maximum of 15";
             *  return;
             * }*/

            //Check if password field is empty
            if (txtPassword.Text == string.Empty)
            {
                txtFieldFocus(txtPassword);
                return;
            }

            String password = txtPassword.Text.Trim();
            //Validate Password for alphanumeric and special characters

            /*if (appValidatorObj.isValidField(password, 8))
             * {
             *  txtFieldFocus(txtPassword);
             * }
             * else
             * {
             *  lblStatus.Text = "Password :"******"1. Must contain at least one digit" + "\n" +
             *                               "2. Must contain at least one uppercase character." + "\n" +
             *                               "3. Must contain at least one special symbol" + "\n" +
             *                               "4. Length at least 8 characters and maximum of 15";
             *  return;
             * }*/

            /**
             * Establish Database Connectivity Based on type of Database Server(MS SQL SERVER if default type)
             * If MY SQL, use IConnector dbConnector = connectionObj.connectToServer("MY SQL");
             * SQL specific methods are stored in interface ISQLConnector which is child of IConnector interface.
             * Similiarly for other types of Database Servers
             * DB Connection takes the database connection string identifier from DbConnection.config file.
             * When "default" is passed, default connection identifier from config file is choosen.
             * Another instance of DBConnection is to be created to connect to different database for
             * file handling.
             */
            DBConnection connectionObj = new DBConnection(AppConstants.DEFAULT_DBCONN_IDENTIFIER);

            DesktopAppSample3.ISQLConnector dbConnector = (DesktopAppSample3.ISQLConnector)connectionObj.connectToServer(AppConstants.MS_SQL_SERVER);

            /**
             * Initialization fields of the application
             * is stored in AppData object. Validate input Username and Password
             * with the values in Database.
             */
            AppData dataObj = getLoginData(username, password, dbConnector);

            if (dataObj != null)
            {
                dataObj.setDBConnector(dbConnector);

                FrmMDIMain mainForm = new FrmMDIMain(); //Pass Data Object to Main Form for using the stored username and other fields.
                this.Hide();
                mainForm.Show();
                txtPassword.Text.Trim();
            }
            else //Invalid entries provided
            {
                lblStatus.Text = "Invalid Username/Password.";
            }
        }
예제 #9
0
 public TodoController(ITodoService appService, AppValidator validator)
 {
     this.appService = appService;
     this.validator  = validator;
 }