/
Model Validation Design by: TEDU Model Validation Design by: TEDU

Model Validation Design by: TEDU - PowerPoint Presentation

bikersnomercy
bikersnomercy . @bikersnomercy
Follow
343 views
Uploaded On 2020-06-30

Model Validation Design by: TEDU - PPT Presentation

Trainer Bach Ngoc Toan Website wwwteducomvn Facebook fbcom teduchannel Please like videos and subscribe TEDU Channel to following the next video 32 Problem Often the data entered by the user is not valid and cannot be saved into the database ID: 790268

model validation properties user validation model user properties data side server errors attributes state values access modelstate list client

Share:

Link:

Embed:

Download Presentation from below link

Download The PPT/PDF document "Model Validation Design by: TEDU" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Model Validation

Design by: TEDUTrainer: Bach Ngoc ToanWebsite: www.tedu.com.vn Facebook: fb.com/teduchannel

Please

like videos and subscribe TEDU Channel to following the next video.

#32

#

Slide2

Problem

Often the data entered by the user is not valid and cannot be saved into the database. The entered data may contain a typo or user may intentionally enter the inappropriate data. 

Slide3

Solution

The ASP.NET Core gives us Model Validator, which uses the validation attributes to validate the model, which makes our task easier. We also take a look at ModelState and how to use it. Finally, we look at the list of Validation attributes.

Slide4

Validation types

Client-side validationServer-side validation

Slide5

Importance of client-side Validation

Better User experiencesSince the validation happens in the client’s browser, the Response is faster and immediate.Saves Precious server resources bandwidth by Minimizing the Server round tripsSince there is no HTTP Request/response round trip involved in the validation, It saves bandwidth & Server resources

Slide6

Importance of server-side Validation

The Javascript may be disabled in the end users browser.The Malicious user can send the data directly to the user, without using the application or use some interceptor modify the HTTP Request.An Error in Javascript code may result in validation to succeed although data is invalid.

Slide7

How Model Validation works

Slide8

ModelState

PROPERTY

TYPE

REMARKS

Keys

KeyEnumerable

Gets the key sequence. The collection of model properties' names. Keys Property gives you Access to state of individual model properties

Values

ValueEnumerable

The model properties' values Get the value sequence.

MaxAllowedErrors

Gets or sets the maximum allowed model state errors in this instance of ModelStateDictionary. Defaults to 200.

HasReachedMaxErrors

bool

Gets a value indicating whether or not the maximum number of errors have been recorded.

IsValid

bool

Whether or not the model is valid

Item

ModelStateEntry

Access to individual model properties' state

Count

Int

The count of model properties

ErrorCount

int

The number of errors that are added to this instance of ModelStateDictionary via AddModelError or TryAddModelError.

Slide9

List of Validation Attributes

CreditCardCompareEmailAddressPhoneRangeRegularExpressionRequiredStringLengthUrl