MvcValidatorToolkit/Validators/ValidateScriptMethod.cs
/// <summary>
/// Validates the given element using the Values collection and generates an error if 
/// invalid.
/// </summary>
Validates the given element using the Values collection and generates an error if
invalid.
Validates the given element using the Values collection and generates an error if invalid .
protected override void Validate(string element)
		{
			MethodInfo mi = ValidationSet.GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
									.Where(m => m.Name.ToLower() == MethodName.ToLower()).SingleOrDefault();
			if(mi != null && mi.ReturnType == typeof(bool) && mi.GetParameters().Count() == 0)
			{
				if(!(bool)mi.Invoke(ValidationSet, null))
					InsertError(element);
			}
		}
protected override void Validate ( string element ) { MethodInfo mi = ValidationSet . GetType ( ) . GetMethods ( BindingFlags . Instance | BindingFlags . NonPublic ) . Where ( m => m . Name . ToLower ( ) == MethodName . ToLower ( ) ) . SingleOrDefault ( ) ; if ( mi != null && mi . ReturnType == typeof ( bool ) && mi . GetParameters ( ) . Count ( ) == 0 ) { if ( ! ( bool ) mi . Invoke ( ValidationSet , null ) ) InsertError ( element ) ; } }
Validates the given element using the Values collection and generates an error if
invalid.
Validates the given element using the Values collection and generates an error if invalid .
// TODO: Call method with parameters or null
element
string