public static ValidationRules AccountRoleCode(ValidationRules rules, object viewModel, object dataContext) { return rules .AddRule("Account Role is required.", delegate(object value) { return (value!=null) && ((OptionSetValue)value).Value!=null; }); }
public static ValidationRules BirthDate(ValidationRules rules, object viewModel, object dataContext) { Contact self = (Contact)viewModel; return rules .AddRule("Birthdate can't be in the future", delegate(object value) { DateTime birthdate =(DateTime)value; return (birthdate < DateTime.Today); }); }
public static ValidationRules PublishDate(ValidationRules rules, object viewModel, object dataContext) { Book self = (Book)viewModel; return rules .AddRule("Publish date can't be more than 1 year in the future", delegate(object value) { DateTime publishDate = (DateTime)value; return (publishDate < DateTimeEx.DateAdd(DateInterval.Days, 365,DateTime.Today)); }); }
public static ValidationRules ProductId(ValidationRules rules, object viewModel, object dataContext) { QuoteDetail self = Knockout.UnwrapObservable<QuoteDetail>(viewModel); return rules .AddRule("Select either a product or provide a product description.", delegate(object value) { // Only a productdescription or productid can be selected string productDescription = Knockout.UnwrapObservable<string>(self.ProductDescription); bool isValid = String.IsNullOrEmpty(productDescription) || (value == null); return isValid; } ); }
public static ValidationRules WriteInProduct(ValidationRules rules, object viewModel, object dataContext) { QuoteDetail self = Knockout.UnwrapObservable<QuoteDetail>(viewModel); return rules .AddRule("Select either a product or provide a product description.", delegate(object value) { // Only a productdescription or productid can be selected EntityReference productid = Knockout.UnwrapObservable<EntityReference>(self.ProductId); bool isValid = String.IsNullOrEmpty((string)value) || (productid == null); return isValid; } ); }
public static ValidationRules ValidateRecord1RoleId(ValidationRules rules, object viewModel, object dataContext) { return rules .AddRule(ResourceStrings.RequiredMessage, delegate(object value) { return (value != null) && ((EntityReference)value).Id != null; }); }
private static ValidationRules ValidateRecord1RoleId(ValidationRules rules, object viewModel, object dataContext) { return rules .AddRule("Required", delegate(object value) { return (value != null) && ((EntityReference)value).Id != null; }); }