Example #1
0
        /// <summary>
        /// Performs a validation check on the current request.
        /// </summary>
        /// <param name="pDescs">Collection of description.</param>
        /// <param name="pRequest">Request object containing parameters.</param>
        /// <returns>True if parameter pass validation.</returns>
        public bool Validate(ICollection <Description> pDescs, Request pRequest)
        {
            if (_messages == null)
            {
                return(true);
            }

            bool result = !Report(MissingRequired(pDescs, pRequest), eERROR.REQUIRED);

            result &= !Report(SelectDuplicates(pDescs, pRequest), eERROR.DUPLICATE);
            result &= !Report(SelectMissingValue(pDescs, pRequest), eERROR.MISSING_VALUE);

            // check for arguments on the command line that have no matching description
            foreach (Argument unknown in from arg in pRequest where arg.Desc == null select arg)
            {
                _messages.Unknown(unknown);
                result = false;
            }

            return(result);
        }