public override void Validate(HttpContextBase ctx, ValidationResultList validationMessages) { var encryptedValue = ctx.Request.Form[HiddenFieldName]; var postedValue = ctx.Request.Form[InputFieldName]; var isValid = Captcha.Decrypt(encryptedValue, out _, out var value) && value == postedValue; if (!isValid) { validationMessages.Add(InputFieldName, Localization.T("Captcha.CompositeC1.Error")); } }
public override void Validate(HttpContextBase ctx, ValidationResultList validationMessages) { var response = ctx.Request.Form[HiddenFieldName]; var ip = ctx.Request.UserHostAddress; var url = $"{SiteVerifyUrl}?secret={_secret}&remoteip={ip}&v={Version}&response={response}"; using (var client = new HttpClient()) { var resultString = client.GetStringAsync(url).Result; var result = JsonConvert.DeserializeObject <Response>(resultString); if (!result.Success) { validationMessages.Add(InputFieldName, String.Join(", ", result.ErrorCodes)); } } }
public void AddValidationResult(ICommandValidationResult validationResult) { ValidationResultList.Add(validationResult); }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Validates this instance. /// </summary> /// <returns></returns> public ValidationResultList Validate() { ValidationResultList vrl = ValidationResultList.Empty; //----------------------------------------------------------------- if (this.PrimaryKey == Guid.Empty) { vrl.Add(Servity.Fatal, "The PrimaryKey Is Empty!", this, "PrimaryKey", this.PrimaryKey); } if (this.Name.IsEmpty() == true) { vrl.Add(Servity.Warning, "The Name Is Empty!", this, "Name", this.Name); } if (this.DeviceSource == DeviceSource.Unknown) { vrl.Add(Servity.Warning, "The DeviceSource Is Unknown!", this, "DeviceSource", this.DeviceSource); } if (this.StartTime < 0) { vrl.Add(Servity.Error, "The StartTime Is Less Than Zero!", this, "StartTime", this.StartTime); } //----------------------------------------------------------------- if (this.Latitude < -90 || this.Latitude > 90) { vrl.Add(Servity.Error, "The Latitude Is Not In The Normal Range (-90/90)!", this, "Latitude", this.Latitude); } if (this.Longitude < -180 || this.Longitude > 180) { vrl.Add(Servity.Error, "The Longitude Is Not In The Normal Range (-180/180)!", this, "Longitude", this.Longitude); } if (this.Altitude > 20000) { vrl.Add(Servity.Warning, "The Altitude Is Over 20000m!", this, "Altitude", this.Altitude); } //----------------------------------------------------------------- //TODO: Question the right values here if (this.Roll < -360 || this.Roll > 360) { vrl.Add(Servity.Warning, "The Roll Is Not In The Normal Range (-360/360)!", this, "Roll", this.Roll); } if (this.Pitch < -90 || this.Pitch > 90) { vrl.Add(Servity.Warning, "The Pitch Is Not In The Normal Range (-90/90)!", this, "Pitch", this.Pitch); } if (this.Yaw < -180 || this.Yaw > 180) { vrl.Add(Servity.Warning, "The Yaw Is Not In The Normal Range (-180/180)!", this, "Yaw", this.Yaw); } //----------------------------------------------------------------- if (this.RxTxType == null) { vrl.Add(Servity.Error, "The RxTxType Is Unknown!", this, "RxTxType", this.RxTxType); } if (this.RxTxType == RxTxTypes.RxTxTypes.Unknown) { vrl.Add(Servity.Warning, "The RxTxType Is Unknown!", this, "RxTxType", this.RxTxType); } // Check The RxTxType At Validation (https://github.com/ObiWanLansi/SIGENCE-Scenario-Tool/issues/154) if (RxTxTypes.RxTxTypes.IsValidForId(this.Id, this.RxTxType) == false) { vrl.Add(Servity.Warning, "The RxTxType Is Not Valid For This Device!", this, "RxTxType", this.RxTxType); } if (this.AntennaType == AntennaType.Unknown) { vrl.Add(Servity.Warning, "The AntennaType Is Unknown!", this, "AntennaType", this.AntennaType); } //----------------------------------------------------------------- // TODO: Validate the following properties: // CenterFrequency_Hz // Bandwith_Hz // Gain_dB // SignalToNoiseRatio_dB //----------------------------------------------------------------- if (this.Remark.IsEmpty() == true) { vrl.Add(Servity.Information, "The Remark Is Empty!", this, "Remark", this.Remark); } //----------------------------------------------------------------- // vrl.Add( Servity., "" , this ); return(vrl); }