private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //OidItem if (OidItem == 0) { e.Description = Resources.Messages.NO_FIELD_SELECTED; throw new iQValidationException(e.Description, string.Empty, "OidItem"); } //Privilege if (Privilege == 0) { e.Description = Resources.Messages.NO_FIELD_SELECTED; throw new iQValidationException(e.Description, string.Empty, "Privilege"); } //OidAssociateItem if (OidAssociateItem == 0) { e.Description = Resources.Messages.NO_FIELD_SELECTED; throw new iQValidationException(e.Description, string.Empty, "OidAssociateItem"); } //AssociatePrivilege if (AssociatePrivilege == 0) { e.Description = Resources.Messages.NO_FIELD_SELECTED; throw new iQValidationException(e.Description, string.Empty, "AssociatePrivilege"); } return(true); }
/// <summary> /// Creates and initializes the rule. /// </summary> /// <param name="target">Reference to the object containing the data to validate.</param> /// <param name="handler">The address of the method implementing the rule.</param> /// <param name="args">A RuleArgs object.</param> public RuleMethod(object target, RuleHandler handler, RuleArgs args) { _target = target; _handler = handler; _args = args; _ruleName = _handler.Method.Name + "!" + _args.ToString(); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Fecha if (Fecha == DateTime.MinValue) { e.Description = string.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "Fecha"); throw new iQValidationException(e.Description, string.Empty); } //FechaRecepcion if (FechaRecepcion == DateTime.MinValue) { e.Description = string.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "FechaRecepcion"); throw new iQValidationException(e.Description, string.Empty); } //Importe if (Importe <= 0) { e.Description = string.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "Importe"); throw new iQValidationException(e.Description, string.Empty); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Codigo if (Codigo == string.Empty) { e.Description = Resources.Messages.NO_ID_SELECTED; throw new iQValidationException(e.Description, string.Empty); } //Serie if (OidSerie == 0) { e.Description = Resources.Messages.NO_SERIE_SELECTED; throw new iQValidationException(e.Description, string.Empty); } //Cliente if (OidCliente == 0) { e.Description = Resources.Messages.NO_CLIENTE_SELECTED; throw new iQValidationException(e.Description, string.Empty); } return(true); }
/// <summary> /// Creates and initializes the rule. /// </summary> /// <param name="target">Reference to the object containing the data to validate.</param> /// <param name="handler">The address of the method implementing the rule.</param> /// <param name="propertyName">The field, property or column to which the rule applies.</param> public RuleMethod(object target, RuleHandler handler, string propertyName) { _target = target; _handler = handler; _args = new RuleArgs(propertyName); _ruleName = _handler.Method.Name + "!" + _args.ToString(); }
/// <summary> /// Adds a rule to the list of rules to be enforced. /// </summary> /// <remarks> /// A rule is implemented by a method which conforms to the /// method signature defined by the RuleHandler delegate. /// </remarks> /// <param name="handler">The method that implements the rule.</param> /// <param name="args"> /// A RuleArgs object specifying the property name and other arguments /// passed to the rule method /// </param> public void AddRule(RuleHandler handler, RuleArgs args) { // get the list of rules for the property List <RuleMethod> list = GetRulesForProperty(args.PropertyName); // we have the list, add our new rule list.Add(new RuleMethod(_target, handler, args)); }
public void AddRule(RuleHandler handler, RuleArgs args, int priority) { // get the list of rules for the property List <IRuleMethod> list = GetRulesForProperty(args.PropertyName, true).GetList(false); // we have the list, add out new rule list.Add(new RuleMethod(handler, args, priority)); }
private static bool MyRegionRequired(Territory target, Csla.Validation.RuleArgs e) { if (target._RegionID == 0 && target._MyRegion == null) // Required field missing { e.Description = "Required"; return(false); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { if (OidCreditCard == 0) { e.Description = Resources.Messages.NO_CREDIT_CARD_SELECTED; throw new iQValidationException(e.Description, string.Empty, "OidCreditCard"); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Expedient if (OidExpedient <= 0) { e.Description = String.Format(moleQule.Resources.Messages.NO_VALUE_SELECTED, Resources.Labels.EXPEDIENT); throw new iQValidationException(e.Description, string.Empty); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Codigo if (Valor == string.Empty) { e.Description = Resources.Messages.NO_CUENTA_SELECTED; throw new iQValidationException(e.Description, string.Empty); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Name if (Name == string.Empty) { e.Description = Resources.Messages.NO_FIELD_FILLED; throw new iQValidationException(e.Description, string.Empty, "Name"); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Propiedad if (OidPrestamo <= 0) { e.Description = String.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "OidPrestamo"); throw new iQValidationException(e.Description, string.Empty); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //OidCuentaBancaria if (OidCuentaBancaria == 0) { e.Description = Resources.Messages.NO_CUENTA_SELECTED; throw new iQValidationException(e.Description, string.Empty, "OidCuentaBancaria"); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Codigo if (Nombre == string.Empty) { e.Description = Resources.Messages.NO_NAME; throw new iQValidationException(e.Description, string.Empty, "Nombre"); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Propiedad /*if (Propiedad <= 0) * { * e.Description = String.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "Propiedad"); * throw new iQValidationException(e.Description, string.Empty); * }*/ return(true); }
public static bool StringRequired(object target, RuleArgs e) { string value = (string)Utilities.CallByName( target, e.PropertyName, CallType.Get); if (string.IsNullOrEmpty(value)) { e.Description = string.Format(Resources.StringRequiredRule, e.PropertyName); return(false); } return(true); }
/// <summary> /// Ensure the Role property value exists /// in RoleList /// </summary> public static bool ValidRole(object target, RuleArgs e) { int role = ((IHoldRoles) target).Role; if (RoleList.GetList().ContainsKey(role)) return true; else { e.Description = "Role must be in RoleList"; return false; } }
/// <summary> /// Rule ensuring an integer value doesn't go below /// a specified value. /// </summary> /// <param name="target">Object containing the data to validate.</param> /// <param name="e">Arguments parameter specifying the name of the /// property to validate.</param> /// <returns><see langword="false"/> if the rule is broken.</returns> public static bool IntegerMinValue(object target, RuleArgs e) { int min = ((IntegerMinValueRuleArgs)e).MinValue; int value = (int)Utilities.CallByName(target, e.PropertyName, CallType.Get); if (value < min) { e.Description = String.Format(Resources.MinValueRule, e.PropertyName, min.ToString()); return(false); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Nombre if (Nombre == string.Empty) { e.Description = Resources.Messages.NO_NAME; throw new iQValidationException(e.Description, string.Empty, "Nombre"); } AgenteBase.ValidateInput((ETipoID)TipoId, "ID", ID); return(true); }
private static bool ShippedDateValid(ShipperOrder target, Csla.Validation.RuleArgs e) { try { DateTime tmp = SmartDate.StringToDate(target._ShippedDate); } catch { e.Description = "Invalid Date"; return(false); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { if (_base.Record.Tipo == 0) { throw new iQValidationException(Resources.Messages.SECURE_ITEM_TIPO_NULL, string.Empty); } if (_base.Record.Name == string.Empty) { throw new iQValidationException(Resources.Messages.SECURE_ITEM_NAME_EMPTY, string.Empty); } return(true); }
/// <summary> /// Gets the property name from the RuleArgs /// object, using the friendly name if one /// is defined. /// </summary> /// <param name="e">Object from which to /// extract the name.</param> /// <returns> /// The friendly property name if it exists, /// otherwise the property name itself. /// </returns> public static string GetPropertyName(RuleArgs e) { string propName = null; if (string.IsNullOrEmpty(e.PropertyFriendlyName)) { propName = e.PropertyName; } else { propName = e.PropertyFriendlyName; } return(propName); }
/// <summary> /// Rule that checks to make sure a value /// matches a given regex pattern. /// </summary> /// <param name="target">Object containing the data to validate</param> /// <param name="e">RegExRuleArgs parameter specifying the name of the /// property to validate and the regex pattern.</param> /// <returns>False if the rule is broken</returns> /// <remarks> /// This implementation uses late binding. /// </remarks> public static bool RegExMatch(object target, RuleArgs e) { Regex rx = ((RegExRuleArgs)e).RegEx; if (!rx.IsMatch(Utilities.CallByName(target, e.PropertyName, CallType.Get).ToString())) { e.Description = String.Format(Resources.RegExMatchRule, e.PropertyName); return(false); } else { return(true); } }
public static bool Required(object target, Csla.Validation.RuleArgs e) { PropertyInfo propertyInfoObj = target.GetType().GetProperty(e.PropertyName); if (propertyInfoObj == null) { return(true); } if (propertyInfoObj.GetValue(target, null) == null) { e.Description = e.PropertyName + " is a required field"; return(false); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Categoria if (_base.Record.Categoria <= 0) { e.Description = Resources.Messages.NO_CATEGORIA_SELECTED; throw new iQValidationException(e.Description, string.Empty); } //Medio Pago if ((EMedioPago == EMedioPago.Seleccione) || (EMedioPago == EMedioPago.Todos)) { e.Description = Resources.Messages.NO_MEDIO_PAGO_SELECTED; throw new iQValidationException(e.Description, string.Empty); } //Cuenta Bancaria switch (EMedioPago) { case EMedioPago.Cheque: case EMedioPago.Giro: case EMedioPago.Ingreso: case EMedioPago.Pagare: case EMedioPago.Tarjeta: case EMedioPago.Transferencia: case EMedioPago.Domiciliacion: case EMedioPago.ComercioExterior: e.Description = Resources.Messages.NO_CUENTA_BANCARIA_SELECTED; if (_base.Record.OidCuentaAsociada == 0) { throw new iQValidationException(e.Description, string.Empty); } break; } //Tarjeta de Credito /*switch (EMedioPago) * { * case EMedioPago.Tarjeta: * e.Description = Resources.Messages.NO_TARJETA_CREDITO_SELECTED; * if (_oid_tarjeta_credito == 0) throw new iQValidationException(e.Description, string.Empty); * break; * }*/ return(true); }
public static bool StringMaxLength( object target, RuleArgs e) { int max = ((MaxLengthRuleArgs)e).MaxLength; string value = (string)Utilities.CallByName( target, e.PropertyName, CallType.Get); if (!String.IsNullOrEmpty(value) && (value.Length > max)) { e.Description = String.Format( Resources.StringMaxLengthRule, e.PropertyName, max.ToString()); return(false); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //if (Valor == string.Empty) //{ // e.Description = String.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "Propiedad"); // throw new iQValidationException(e.Description, string.Empty); //} //Tipo if (Tipo <= 0) { e.Description = String.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "Tipo"); throw new iQValidationException(e.Description, string.Empty); } return(true); }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { ////OidSubtipoFacturaEmitida //if (OidSubtipoFacturaEmitida <= 0) //{ // e.Description = String.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "OidSubtipoFacturaEmitida"); // throw new iQValidationException(e.Description, string.Empty); //} ////OidSubtipoFacturaRecibida //if (OidSubtipoFacturaRecibida <= 0) //{ // e.Description = String.Format(Library.Resources.Messages.NO_VALUE_SELECTED, "OidSubtipoFacturaRecibida"); // throw new iQValidationException(e.Description, string.Empty); //} return(true); }
/// <summary> /// Rule ensuring that a numeric value /// doesn't exceed a specified minimum. /// </summary> /// <typeparam name="T">Type of the property to validate.</typeparam> /// <param name="target">Object containing value to validate.</param> /// <param name="e">Arguments variable specifying the /// name of the property to validate, along with the min /// allowed value.</param> public static bool MinValue <T>(object target, RuleArgs e) where T : IComparable { PropertyInfo pi = target.GetType().GetProperty(e.PropertyName); T value = (T)pi.GetValue(target, null); T min = ((MinValueRuleArgs <T>)e).MinValue; int result = value.CompareTo(min); if (result <= -1) { e.Description = string.Format(Resources.MinValueRule, e.PropertyName, min.ToString()); return(false); } else { return(true); } }
private bool CheckValidation(object target, Csla.Validation.RuleArgs e) { //Codigo if (Code == string.Empty) { e.Description = Resources.Messages.NO_ID_SELECTED; throw new iQValidationException(e.Description, string.Empty); } //Nombre if (Name == string.Empty) { e.Description = String.Format(Resources.Messages.NO_FIELD_FILLED, "Nombre"); throw new iQValidationException(e.Description, string.Empty); } //ID AgenteBase.ValidateInput((ETipoID)TipoID, "ID", VatNumber); return(true); }
private bool NoDuplicates(object target, RuleArgs e) { Roles parent = (Roles) Parent; foreach (Role item in parent) if (item.Id == _id && !ReferenceEquals(item, this)) { e.Description = "Role Id must be unique"; return false; } return true; }
static public bool ComboRequired(object target, RuleArgs e) { e.Description = e.PropertyName + " is required"; return (int)Utilities.CallByName(target, e.PropertyName, CallType.Get) > 0; }
//Public Function DateRequired(ByVal target As Object, ByVal e As BrokenRules.RuleArgs) As Boolean // e.Description = e.PropertyName & " is required" // Return Not DirectCast(CallByName(target, e.PropertyName, CallType.Get), SmartDate).IsEmpty //End Function static public bool DateRequired(object target, RuleArgs e) { e.Description = e.PropertyName + " is required"; return ((string)Utilities.CallByName(target, e.PropertyName, CallType.Get)).Length > 0; }
/// <summary> /// Gets the property name from the RuleArgs /// object, using the friendly name if one /// is defined. /// </summary> /// <param name="e">Object from which to /// extract the name.</param> /// <returns> /// The friendly property name if it exists, /// otherwise the property name itself. /// </returns> public static string GetPropertyName(RuleArgs e) { string propName = null; if (string.IsNullOrEmpty(e.PropertyFriendlyName)) propName = e.PropertyName; else propName = e.PropertyFriendlyName; return propName; }
static public bool DateIsInPast(object target, RuleArgs e) { e.Description = e.PropertyName + " must be in the past"; return (System.DateTime)Utilities.CallByName(target, e.PropertyName, CallType.Get) < System.DateTime.Now; }