Several problems with setting up a Range Validator (EL 5.0)

Topics: Validation Application Block
Apr 28, 2014 at 11:22 AM
Edited Apr 28, 2014 at 11:26 AM
Hello fellas,

I want to provide my app with RangeValidator to check if the inserted value is from the specified range.

It works fine e.g for int? vals foto

I'm said I've to work on decimal, but sth like this doesn't compile:
        private decimal? _Code;
        [NotNullValidator]
        [RangeValidator
             (0.0m, RangeBoundaryType.Inclusive, 120.0m, RangeBoundaryType.Inclusive)
        ]
        public decimal? Code
        {
            get
            {
                return _Code;
            }
            set
            {
                if (_Code == value)
                    return;
                _Code = value;
                OnPropertyChanged(() => Code);

                codeValidator.Validate(this);
            }
        }
How to deal with it?
Thx 4 your repl xD
Apr 28, 2014 at 1:56 PM
You will need to explicitly supply the type:
        private decimal? _Code;

        [NotNullValidator]
        [RangeValidator(typeof(decimal), "0.00", RangeBoundaryType.Inclusive, "1000.00", RangeBoundaryType.Inclusive)]
        public decimal? Code
        {
            get
            {
                return _Code;
            }
            set
            {
                if (_Code == value)
                    return;
                _Code = value;
                OnPropertyChanged(() => Code);

                codeValidator.Validate(this);
            }
        }
~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Marked as answer by spazi on 4/28/2014 at 6:11 AM
Apr 28, 2014 at 2:11 PM
Wow, I'm very glad to get the answer so quickly - I'm paying homage to U

Regards