dotnet/aspnetcore

Incorrect validation of floating point data

Open

#6.326 aberto em 3 de jan. de 2019

Ver no GitHub
 (4 comments) (2 reactions) (0 assignees)C# (10.653 forks)batch import
affected-fewarea-mvcbugfeature-mvc-razor-viewshelp wantedseverity-minor

Métricas do repositório

Stars
 (37.933 stars)
Métricas de merge de PR
 (Mesclagem média 16d 9h) (258 fundiu PRs em 30d)

Description

Data of floating point types are incorrectly forced to be numbers in general format by client-side validation, without accounting for the possibility of values displayed or inserted in scientific notation. The data-val-number tag is automatically added to, and cannot be trivially removed from the generated HTML. This causes an inconsistency because it suffices to define a default value small or big enough to be displayed in scientific notation (say, 1.0e-5) to receive a validation error at submission even if the entry is perfectly valid.

To Reproduce

Steps to reproduce the behavior:

  1. Create a model with a double data member.
  2. Scaffold a Razor Page with CRUD for the model at point 1.
  3. Try to insert a value in scientific notation in the text box for the variable of double type.
  4. See error

Expected behavior

There are two possibilities: a) values in scientific notation are accepted b) a custom validator should be able to override the data-val-number setting

Guia do colaborador