Created
October 6, 2014 23:01
-
-
Save McGaiser/dca33db8faff47af1b3f to your computer and use it in GitHub Desktop.
AssignmentTable Validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function validationDefault(Validator $validator) { | |
return $validator | |
->validatePresence('role_id') | |
->notEmpty('role_id', 'A role is required') | |
->add('role_id', [ | |
'unique' => [ | |
'rule' => function($value, $context){ | |
//debug($context); | |
return $context['data']['isUnique']; | |
}, | |
'message' => 'The role you have selected has reached its maximum assignments.' | |
] | |
]) | |
->validatePresence('venue_id') | |
->allowEmpty('venue_id') | |
->add('venue_id', [ | |
'validVenue' => [ | |
'rule' => function($value, $context){ | |
return $context['data']['validVenue']; | |
}, | |
'message' => 'The role you have selected must have a venue assigned to it.' | |
], | |
'properVenue' => [ | |
'rule' => function($value, $context){ | |
return $context['data']['properVenue']; | |
}, | |
'message' => 'The role you have selected cannot have a venue assigned to it.' | |
], | |
]) | |
->notEmpty('member_id', 'A member is required') | |
->notEmpty('domain_id', 'A domain is required') | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment