Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

Commented Unassigned: "'RuleFor' is not supported by the language" in Silverlight application [7181]

$
0
0
When I use portable library in Silverlight 4 application, I get this error: "'RuleFor' is not supported by the language".

Here is code snippet:
{{
namespace FluentValidationCheck
{
public partial class MainPage : UserControl
{
public string Title { get; set; }

public MainPage()
{
InitializeComponent();

Title = "hello world";

var validator = new MainPageValidator();
ValidationResult result = validator.Validate(this);

if (!result.IsValid)
{
IList<ValidationFailure> failures = result.Errors;
MessageBox.Show(failures[0].ErrorMessage);
}
}
}

public class MainPageValidator : AbstractValidator<MainPage>
{
public MainPageValidator()
{
RuleFor(page => page.Title).Length(1, 5).WithMessage("Title must be less then 5 symbols");
}
}
}
}}

Compilation error occurs in this line
{{ RuleFor(page => page.Title).Length(1, 5).WithMessage("Title must be less then 5 symbols"); }}

Example solution can be dowloaded here: http://yadi.sk/d/ivGAMuxNQP7TH
Comments: FluentValidation doesn't support Silverlight 4 I'm afraid. If you want to use FV with Silverlight you'll need to be running SL5 or above. Sorry.

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>