Skip to content

Instantly share code, notes, and snippets.

@McGaiser
Created October 6, 2014 23:01
Show Gist options
  • Save McGaiser/dca33db8faff47af1b3f to your computer and use it in GitHub Desktop.
Save McGaiser/dca33db8faff47af1b3f to your computer and use it in GitHub Desktop.
AssignmentTable Validator
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