2.4.2

Validation and Sanitation

Test yourself

Validation and Sanitation

Validation and sanitation can help to protect against malicious inputs such as SQL injection attacks.

Illustrative background for Input sanitationIllustrative background for Input sanitation ?? "content

Input sanitation

  • Input sanitation involves the removal of unwanted characters from input data.
  • This is a chief line of defence against attacks such as the SQL injection attack.
  • Any data entered by users which might be executed or become part of a query should first be sanitised.
Illustrative background for Input validationIllustrative background for Input validation ?? "content

Input validation

  • Input validation is the process of making sure that input data meets certain criteria.
  • If a user's data is rejected, they should be informed and asked to enter it again.
Illustrative background for Input validation rulesIllustrative background for Input validation rules ?? "content

Input validation rules

  • Type checks check the type (e.g. Integer) of the input.
  • Range checks check that the data is inside an allowed range, e.g. less than 100.
  • Presence checks check that the required data has been input.
  • Format checks check that the data fits a set format, e.g. an email address has an @ symbol.
  • Length checks check that the number of characters entered is inside a permitted range.

Jump to other topics

1Problem Solving

2Programming

3Data

4Computers

5Communication & The Internet

6The Bigger Picture

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium