Skip to content

Commit

Permalink
add elrond address rule
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Aug 10, 2022
1 parent a33c8db commit 6d983c0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Rules/ElrondAddressRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Superciety\ElrondSdk\Rules;

use Illuminate\Contracts\Validation\InvokableRule;

class ElrondAddressRule implements InvokableRule
{
const Regex = '/erd1[a-z0-9]{58}/';

/**
* Run the validation rule.
*
* @param string $attribute
* @param mixed $value
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
* @return void
*/
public function __invoke($attribute, $value, $fail)
{
if (! preg_match_all(self::Regex, $value)) {
$fail('The :attribute must be a valid Elrond address.');
}
}
}

0 comments on commit 6d983c0

Please sign in to comment.