示例#1
0
        /// <summary>
        ///     数据校验
        /// </summary>
        /// <param name="status">检查状态</param>
        /// <returns>成功则返回真</returns>
        public virtual bool Validate(out IOperatorStatus status)
        {
            status = ApiResultHelper.Succees();
            var msg = new StringBuilder();

            status.Success = true;
            if (PageIndex < 0)
            {
                status.Success = false;
                msg.Append("页号必须大于或等于0");
            }

            if (PageSize <= 0 || PageSize > 100)
            {
                status.Success = false;
                msg.Append("行数必须大于0且小于100");
            }
            if (status.Success)
            {
                return(true);
            }
            status.Message = msg.ToString();
            status.Code    = OperatorStatusCode.ArgumentError;
            return(status.Success);
        }
示例#2
0
 /// <summary>
 ///     参数校验
 /// </summary>
 /// <param name="data"></param>
 /// <param name="status"></param>
 /// <returns></returns>
 public bool ValidateArgument(IInlineMessage data, out IOperatorStatus status)
 {
     if (ArgumentType == null || Option.HasFlag(ApiOption.DictionaryArgument) || Option.HasFlag(ApiOption.CustomContent))
     {
         status = null;
         return(true);
     }
     if (data.ArgumentData == null && !Option.HasFlag(ApiOption.ArgumentCanNil))
     {
         status = ApiResultHelper.State(OperatorStatusCode.ArgumentError, "参数不能为空");
         return(false);
     }
     if (data.ArgumentData is IApiArgument arg)
     {
         return(arg.Validate(out status));
     }
     status = null;
     return(true);
 }