createValidatorInfo() 공개 정적인 메소드

Given a callback and an optional sound to play on error, this will return a validator information structure to be used with validateInputWith().
public static createValidatorInfo ( Closure $validation, string | null $soundOnError = null ) : validatorInfo
$validation Closure Callback to use as validator
$soundOnError string | null Sound file to play on error
리턴 validatorInfo
예제 #1
0
파일: example.php 프로젝트: marcelog/pagi
 public function getCommonCallingCardValidations()
 {
     return array('cardExists' => Node::createValidatorInfo(function (Node $node) {
         $node->saveCustomData('myCardEntity', new Card());
         return true;
     }, 'pp/11'), 'cardIsNotExpired' => Node::createValidatorInfo(function (Node $node) {
         $card = $node->getCustomData('myCardEntity');
         return !$card->isExpired();
     }, 'pp/12'), 'cardIsNotDued' => Node::createValidatorInfo(function (Node $node) {
         $card = $node->getCustomData('myCardEntity');
         return !$card->isDued();
     }, 'pp/15'), 'cardIsNotInUse' => Node::createValidatorInfo(function (Node $node) {
         $card = $node->getCustomData('myCardEntity');
         return !$card->inUse();
     }, 'pp/34'));
 }
예제 #2
0
파일: Test_Node.php 프로젝트: marcelog/pagi
 /**
  * @test
  */
 public function can_create_validator_info()
 {
     $validatorInfo = Node::createValidatorInfo(function ($node) {
         return true;
     }, 'sound');
     $this->assertEquals($validatorInfo['soundOnError'], 'sound');
     $this->assertTrue($validatorInfo['callback'](null));
 }