Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Added MacAddress rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Alphametric committed Apr 8, 2019
1 parent 7a5cdcf commit d33c6f5
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 376 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ The following validation rules are currently available:
| Decimal | validation.decimal | Requires that the given value is a decimal with an appropriate format - see class for details |
| EncodedImage | validation.encoded_image | Requires that the given value is a base64-encoded image of a given mime type - see class for details |
| LocationCoordinates | validation.location_coordinates | Requires that the given value is a comma-separated set of latitude and longitude coordinates |
| DateTimeBefore | validation.datetime_before | Requires that the given value is before a given date - see class for details |
| DateTimeAfter | validation.datetime_after | Requires that the given value is after a given date - see class for details |
| DateTimeBetween | validation.datetime_between | Requires that the given value is between two dates - see class for details |
| FileExists | validation.file_exists | Requires that the given value is a path to an existing file - see class for details |
| Equals | validation.equals | Requires that the given value is equal to another given value |
| MacAddress | validation.mac_address | Requires that the given value is a valid MAC address |

The package will receive new rules over time, however since these updates will not be breaking changes, they will not receive major version numbers unless Laravel changes in such a way that the package requires a re-write.

Expand Down
92 changes: 0 additions & 92 deletions src/DateTimeAfter.php

This file was deleted.

92 changes: 0 additions & 92 deletions src/DateTimeBefore.php

This file was deleted.

108 changes: 0 additions & 108 deletions src/DateTimeBetween.php

This file was deleted.

40 changes: 40 additions & 0 deletions src/MacAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

// Namespace
namespace Alphametric\Validation\Rules;

// Mac address rule
class MacAddress extends Rule
{

/**
* Determine if the validation rule passes.
*
* @param string $attribute.
* @param mixed $value.
* @return bool.
*
**/
public function passes($attribute, $value)
{
return preg_match("/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/", $value);
}



/**
* Get the validation error message.
*
* @param none.
* @return string.
*
**/
public function message()
{
return Helper::getLocalizedErrorMessage(
'mac_address',
'The :attribute must be a valid MAC address'
);
}

}
26 changes: 0 additions & 26 deletions tests/DateTimeAfterTest.php

This file was deleted.

Loading

0 comments on commit d33c6f5

Please sign in to comment.