Example #1
0
?>

		<?php 
# Ex 5 :
# Check if the credit card number is composed of exactly 16 digits.
# Check if the Visa card starts with 4 and MasterCard starts with 5.
# } elseif () {
if (preg_match('/^4\\d{15}$/', $_POST['card'])) {
    if ($_POST['cc'] != 'visa') {
        errorr("You didn't provide a valid credit card number.");
    }
} else {
    if (preg_match('/^5\\d{15}$/', $_POST['card'])) {
        errorr("You didn't provide a valid credit card number.");
    } else {
        errorr("You didn't provide a valid credit card number.");
    }
}
?>

		<!-- Ex 5 : 
			Display the below error message : 
			<h1>Sorry</h1>
			<p>You didn't provide a valid credit card number. Try again?</p>
		--> 

		<?php 
# if all the validation and check are passed
# } else {
?>
 /**
  * register errors
  *
  * @param array $errors
  * @return $this
  */
 public function withErrors($errors = [])
 {
     errorr()->setErrors($errors)->run();
     return $this;
 }