Exemplo n.º 1
0
        public static bool ValidateList(List list, out List <KeyValuePair <ListValidationCodes, KeyValuePair <string, string> > > errorMsgDic)
        {
            var isValid = true;

            errorMsgDic = new List <KeyValuePair <ListValidationCodes, KeyValuePair <string, string> > >();
            if (list.Name == null)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <ListValidationCodes, KeyValuePair <string, string> >(ListValidationCodes.ListNameIsNull, new KeyValuePair <string, string>("Name", Resx.ListResources.ListNameIsNull)));
            }
            else if (list.Name == string.Empty)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <ListValidationCodes, KeyValuePair <string, string> >(ListValidationCodes.ListNameIsEmpty, new KeyValuePair <string, string>("Name", Resx.ListResources.ListNameIsEmpty)));
            }
            else if (list.Name.Length > TrelloSizeConstants.ListNameSize)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <ListValidationCodes, KeyValuePair <string, string> >(ListValidationCodes.ListNameBiggerThanMaxValue, new KeyValuePair <string, string>("Name", Resx.ListResources.ListNameBiggerThanMaxValue)));
            }
            else if (!TrelloRegularExpressions.IsValidBoardName(list.Name))
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <ListValidationCodes, KeyValuePair <string, string> >(ListValidationCodes.ListNameSpecialChars, new KeyValuePair <string, string>("Name", Resx.ListResources.ListNameSpecialChars)));
            }
            if (list.Lix < 0)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <ListValidationCodes, KeyValuePair <string, string> >(ListValidationCodes.ListIndexNegative, new KeyValuePair <string, string>("Lix", Resx.ListResources.ListIndexNegative)));
            }
            return(isValid);
        }
Exemplo n.º 2
0
        public static bool ValidateCard(Card card, out List <KeyValuePair <CardValidationCodes, KeyValuePair <string, string> > > errorMsgDic)
        {
            var isValid = true;

            errorMsgDic = new List <KeyValuePair <CardValidationCodes, KeyValuePair <string, string> > >();
            if (card.Name == null)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardNameIsNull, new KeyValuePair <string, string>("Name", Resx.CardResources.CardNameIsNull)));
            }
            else if (card.Name == string.Empty)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardNameIsEmpty, new KeyValuePair <string, string>("Name", Resx.CardResources.CardNameIsEmpty)));
            }
            else if (card.Name.Length > TrelloSizeConstants.CardNameSize)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardNameBiggerThanMaxValue, new KeyValuePair <string, string>("Name", Resx.CardResources.CardNameBiggerThanMaxValue)));
            }
            else if (!TrelloRegularExpressions.IsValidCardName(card.Name))
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardNameSpecialChars, new KeyValuePair <string, string>("Name", Resx.CardResources.CardNameSpecialChars)));
            }

            if (card.Discription == null)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardDiscpriptionIsNull, new KeyValuePair <string, string>("Discription", Resx.CardResources.CardDiscpriptionIsNull)));
            }
            else if (card.Discription == string.Empty)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardDiscriptionIsEmpty, new KeyValuePair <string, string>("Discription", Resx.CardResources.CardDiscriptionIsEmpty)));
            }
            else if (card.Discription.Length > TrelloSizeConstants.CardNameSize)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardDiscriptionBiggerThanMaxValue, new KeyValuePair <string, string>("Discription", Resx.CardResources.CardDiscriptionBiggerThanMaxValue)));
            }
            else if (!TrelloRegularExpressions.IsValidCardDiscription(card.Discription))
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardDiscriptionSpecialChars, new KeyValuePair <string, string>("Discription", Resx.CardResources.CardDiscriptionSpecialChars)));
            }
            if (card.Cix < 0)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardIndexNegative, new KeyValuePair <string, string>("Cix", Resx.CardResources.CardIndexNegative)));
            }

            if (card.CreationDate > card.DueDate)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <CardValidationCodes, KeyValuePair <string, string> >(CardValidationCodes.CardCreationDateSuperiorToDueDate, new KeyValuePair <string, string>("DueDate", Resx.CardResources.CardCreationDateSuperiorToDueDate)));
            }
            return(isValid);
        }
Exemplo n.º 3
0
        public static bool ValidateBoard(Board board, List <Board> boardNames, out List <KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> > > errorMsgDic)
        {
            var isValid = true;

            errorMsgDic = new List <KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> > >();
            if (board.Name == null)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardNameIsNull, new KeyValuePair <string, string>("Name", Resx.BoardResources.BoardDiscpriptionIsNull)));
            }
            else if (board.Name == string.Empty)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardNameIsEmpty, new KeyValuePair <string, string>("Name", Resx.BoardResources.BoardDiscriptionIsEmpty)));
            }
            else if (board.Name.Length > TrelloSizeConstants.BoardNameSize)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardNameBiggerThanMaxValue, new KeyValuePair <string, string>("Name", Resx.BoardResources.BoardNameBiggerThanMaxValue)));
            }
            else if (!TrelloRegularExpressions.IsValidBoardName(board.Name))
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardNameSpecialChars, new KeyValuePair <string, string>("Name", Resx.BoardResources.BoardNameSpecialChars)));
            }
            else if (boardNames != null && boardNames.Any(b => b.BoardId != board.BoardId && b.Name == board.Name))
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardNameAlreadyExists, new KeyValuePair <string, string>("Name", Resx.BoardResources.BoardNameAlreadyExists)));
            }

            if (board.Discription == string.Empty)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardDiscriptionIsEmpty, new KeyValuePair <string, string>("Discription", Resx.BoardResources.BoardDiscriptionIsEmpty)));
            }
            else if (board.Discription == null)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardDiscpriptionIsNull, new KeyValuePair <string, string>("Discription", Resx.BoardResources.BoardDiscpriptionIsNull)));
            }
            else if (board.Discription.Length > TrelloSizeConstants.BoardDiscriptionSize)
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardDiscriptionBiggerThanMaxValue, new KeyValuePair <string, string>("Discription", Resx.BoardResources.BoardDiscriptionBiggerThanMaxValue)));
            }
            else if (!TrelloRegularExpressions.IsValidBoardDiscription(board.Discription))
            {
                isValid = false;
                errorMsgDic.Add(new KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> >(BoardValidationCodes.BoardDiscriptionSpecialChars, new KeyValuePair <string, string>("Discription", Resx.BoardResources.BoardDiscriptionSpecialChars)));
            }
            return(isValid);
        }