<commit_before>ValidatableBase
===============
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/scionwest/ValidatableBase?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Model Validation for Universal WinRT Apps through delegate method invocation per-property or DataAnnotation styled attribute validation. Universal WinRT apps targeting Windows 8.1 and Windows Phone 8.1 lack built in, easy to use data Validation, so ValidatableBase was created.

### Documentation added

Check out the [new documentation added to the wiki](https://github.com/scionwest/ValidatableBase/wiki). Basic and advance use-cases using ValidatableBase

ValidatableBase Version 2.0 Released
------------------------------------

* With this release, a new DataAnnotation styled attribute validation system has been added.
* Registering properties is no longer needed.
* The library is now in a Portable Class Library, usable across all platforms that PCL's can run on. 
  *   As a side-effect of this, the validation messages collection is no longer directly exposed. The underlying implementation is `Dictionary<string, IEnumerable<IValidationMessage>>` which requires conversion if you need to bind to the validation results. The example app includes an extension method that can be used to perform the conversion, for view models that want to expose validation to the view.
* ValidatableBase now has a ValidationChanged event that you can subscribe to. Any time validation is changed, either by adding/removing messages or running validation, your view models can be notified.

An example model, providing validation making sure the email property is not blank.

    public class User : ValidatableBase, INotifyPropertyChanged
    {
        [ValidateObjectHasValue(FailureMessage = "E-Mail can not be left blank.", ValidationMessageType = typeof(ValidationErrorMessage))]
        public string Email { get; set; }

## Advanced Example validating multiple business rules on a property, for multiple properties.

In this example, the User model has been extended a bit. Now we validate that the E-mail address is not blank and that it is in a valid format. Once E-mail validation is successful, the model will validate its Password property.

    public class User : ValidatableBase, INotifyPropertyChanged
    {
        /// <summary>
        /// The Email backing field.
        /// </summary>
        private string email = string.Empty;

        /// <summary>
        /// The Password backing field.
        /// </summary>
        private string password = string.Empty;

        /// <summary>
        /// Gets the Email.
        /// </summary>
        [ValidateObjectHasValue(FailureMessage = "E-Mail can not be left blank.", ValidationMessageType = typeof(ValidationErrorMessage))]
        [ValidateWithCustomHandler(DelegateName = "ValidateEmailFormat", ValidationMessageType = typeof(ValidationErrorMessage), FailureMessage = "Email address is not properly formatted.")]
        public string Email
        {
            get
            {
                return this.email;<commit_msg>Updated to mention new validation intercept method<commit_after>ValidatableBase
===============
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/scionwest/ValidatableBase?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Model Validation for Universal WinRT Apps through delegate method invocation per-property or DataAnnotation styled attribute validation. Universal WinRT apps targeting Windows 8.1 and Windows Phone 8.1 lack built in, easy to use data Validation, so ValidatableBase was created.

### Documentation added

Check out the [new documentation added to the wiki](https://github.com/scionwest/ValidatableBase/wiki). Basic and advance use-cases using ValidatableBase

ValidatableBase Version 2.1 Released
------------------------------------

Added validation interception support. You may now have the built-in validation rules invoke a delegate method. This provides you with a little more flexibility when performing validation. You may piggy back on top of existing rules for minor checks instead of resorting to a full delegate validation method.

An example model, providing validation making sure the email property is not blank.

    public class Bank
    {
        public const decimal MinimumBalance = 2000M;
        
        [ValidateObjectHasValue(
            FailureMessage = "The bank must be open.",
            ValidationMessageType = typeof(ValidationErrorMessage),
            InterceptionDelegate = "Validate its not sunday")]
        public bool IsOpen { get; set; }
        
        [ValidationCustomHandlerDelegate(DelegateName = "Validate its not sunday")]
        public IValidationMessage IsOpenValidationIntercept(IValidationMessage failureMessage, PropertyInfo property)
        {
            // Is Open is allowed to be false on Sundays.
            if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
            {
                return null;
            }
            
            // It's not sunday, so return the failure message generated
            // by the attribute.
            return failureMessage;
        }
    }

## Advanced Example validating multiple business rules on a property, for multiple properties.

In this example, the User model has been extended a bit. Now we validate that the E-mail address is not blank and that it is in a valid format. Once E-mail validation is successful, the model will validate its Password property.

    public class User : ValidatableBase, INotifyPropertyChanged
    {
        /// <summary>
        /// The Email backing field.
        /// </summary>
        private string email = string.Empty;

        /// <summary>
        /// The Password backing field.
        /// </summary>
        private string password = string.Empty;

        /// <summary>
        /// Gets the Email.
        /// </summary>
        [ValidateObjectHasValue(FailureMessage = "E-Mail can not be left blank.", ValidationMessageType = typeof(ValidationErrorMessage))]
        [ValidateWithCustomHandler(DelegateName = "ValidateEmailFormat", ValidationMessageType = typeof(ValidationErrorMessage), FailureMessage = "Email address is not properly formatted.")]
        public string Email
        {
            get
            {
                return this.email;
{'fraction_non_alphanumeric': 0.08274675426247458, 'fraction_numerical': 0.002502737368997341, 'mean_word_length': 3.0596825396825396, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '157532', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1454, 'n_words': 630}