User has coins. Their number in the field should not exceed their number in the database.

coin.cshtml:

@Html.EditorFor(model => model.coin) 

User coins are specified in the database (I can get the coin value of the user in the CoinController controller)

 public class Coin { [Key] public int id { get; set; } public double coins { get; set; } 

    1 answer 1

    You will not believe, but RangeAttribute

    • This will limit the maximum possible number of models. But the user may have a smaller number. - codename0082016
    • @ codename0082016 Why? The maximum and minimum is set if I understand you correctly. Or you want to calculate restriction in runtime? In this case, you need a custom model binder, which will add a model state error in which case. - free_ze
    • @ codename0082016 In general, this is already a business rule that should be checked at the level of business logic (at least the backend, but also at the front can be). - free_ze