0
votes

Within my entity framework model I have:

<Required(), Range(0, Double.MaxValue, ErrorMessage:="Weight must be numeric and cannot be negative")> _
Public Property Weight() As Double

<Required(), Range(0, Double.MaxValue, ErrorMessage:="Recycled content must be numeric and between 0 and 100")> _
Public Property RecycledContent() As Double

And in my viewmodel I have:

        if (!editComponent().entityAspect.validateProperty("recycledContent")) {
            /* do something about errors */
            var msg = 'Recycled content is invalid!';
            logger.logError(msg, error, system.getModuleId(lt_articleEdit), true);
        }

And yet when I enter a value greater than 100 (in the recycled content field) it still passes validation somehow! I have used the script debugger to step through and in the breeze validation routine there are two validators registered which are "required" and "number" but nothing that I can see mentions the range.

Can breeze do range validation? All I'm trying to do is pick up a data validation error based on metadata from the data annotations of the model and use this to trigger a client-side highlight on the field in error and log an error message.

1

1 Answers

0
votes

It's a very reasonable request but we aren't quite there yet.

Right now Breeze doesn't YET pick up Range validations from Entity Framework metadata. Please vote for this on the Breeze User Voice . This matters because we do prioritize our work based on this venue.