public override bool Validate () { if (!parms.Validate () || !retval.Validate ()) { Console.Write ("in virtual method " + Name + " "); vstate = ValidState.Invalid; return false; } vstate = ValidState.Valid; return true; }
public override bool Validate(LogWriter log) { if (vstate != ValidState.Unvalidated) return vstate == ValidState.Valid; vstate = ValidState.Valid; log.Member = Name; if (!parms.Validate (log) || !retval.Validate (log)) { vstate = ValidState.Invalid; return false; } call = new ManagedCallString (parms); return true; }
public void CurrentCount_WhenInvokedInitially_Returs0() { ValidState state = new ValidState(null, 100, TimeSpan.FromSeconds(5)); Assert.AreEqual(0, state.CurrentCount); }
public override bool Validate () { if (vstate != ValidState.Unvalidated) return vstate == ValidState.Valid; vstate = ValidState.Valid; if (!parms.Validate () || !retval.Validate ()) { vstate = ValidState.Invalid; } if (vstate == ValidState.Invalid) { Console.WriteLine ("(in virtual method " + container_type.QualifiedName + "." + Name + ")"); return false; } else { // The call string has to be created *after* the params have been validated since the Parameters class contains no elements before validation call = new ManagedCallString (parms); return true; } }
private static ValidState validateIEnumerable(Doc self, ObjectGraph graph, IEnumerable enm, ValidState state, string scope) { foreach (var v in enm) { if (state.ShouldStop) { break; } if (v is IValidatable vv && !graph.Visited(vv)) { state = vv.Validate(state, scope); } } return(state); }
private static ValidState validateIDictionary(Doc self, ObjectGraph graph, IDictionary dict, ValidState state, string scope) { foreach (var v in dict.Values) { if (state.ShouldStop) { break; } if (v is IValidatable vv && !graph.Visited(vv)) { state = vv.Validate(state, scope); } } return(state); }
private static ValidState validateIValidatable(Doc self, ObjectGraph graph, IValidatable validatable, ValidState state, string scope) => !graph.Visited(validatable) ? validatable.Validate(state, scope) : state;
/// <summary> /// Validates document field using Schema.FieldDef settings. /// This method is invoked by base Validate() implementation. /// The method is not expected to throw exception in case of failed validation, rather return exception instance because /// throwing exception really hampers validation performance when many rows need to be validated /// </summary> public virtual ValidState ValidateField(ValidState state, Schema.FieldDef fdef, string scope = null) { if (fdef == null) { throw new FieldValidationException(Schema.DisplayName, CoreConsts.NULL_STRING, StringConsts.ARGUMENT_ERROR + ".ValidateField(fdef=null)"); } var atr = fdef[state.TargetName]; if (atr == null) { return(state); //not found per target } var value = GetFieldValue(fdef); var(hasValue, error) = CheckValueRequired(state.TargetName, fdef, atr, value, scope); if (error != null) { return(new ValidState(state, error)); } if (!hasValue) { return(state); //nothing else left to check } state = CheckValueIValidatable(state, fdef, atr, value, scope); if (state.ShouldStop) { return(state); } error = CheckValueLength(state.TargetName, fdef, atr, value, scope); if (error != null) { state = new ValidState(state, error); if (state.ShouldStop) { return(state); } } error = CheckValueKind(state.TargetName, fdef, atr, value, scope); if (error != null) { state = new ValidState(state, error); if (state.ShouldStop) { return(state); } } error = CheckValueMinMax(state.TargetName, fdef, atr, value, scope); if (error != null) { state = new ValidState(state, error); if (state.ShouldStop) { return(state); } } error = CheckValueRegExp(state.TargetName, fdef, atr, value, scope); if (error != null) { state = new ValidState(state, error); if (state.ShouldStop) { return(state); } } //this is at the end as ValueList check might induce a database call to get a pick list (when it is not cached) error = CheckValueList(state.TargetName, fdef, atr, value, scope); if (error != null) { state = new ValidState(state, error); if (state.ShouldStop) { return(state); } } return(state); }
public override ValidState Validate(ValidState state) { Aver.IsNotNull(m_Module); return(base.Validate(state)); }