Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Web;
- namespace ExamenVoorbeeld.Models
- {
- public class VluchtIDVerification : ValidationAttribute
- {
- public override bool IsValid(object value)
- {
- if (!(value is String))
- return false;
- String val = value.ToString();
- if (string.IsNullOrWhiteSpace(val))
- return false;
- String[] dat = val.Split('/');
- if (dat.Length != 3)
- return false;
- int errorCode = -1;
- if (!Int32.TryParse(dat[2],out errorCode))
- return false;
- int valNumberBack = Int32.Parse(dat[2]);
- if (!Int32.TryParse(dat[0], out errorCode))
- return false;
- int valNumberFront = Int32.Parse(dat[0]);
- if (999 - valNumberFront == valNumberBack)
- return true;
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement