def build_validator(): moh_validator = MOHExists('music_on_hold', moh_dao.get_by) return ValidationGroup( delete=[NoVoicemailAssociated(), NoLineAssociated(user_line_dao)], create=[ Optional( 'email', UniqueField('email', lambda email: user_dao.find_by(email=email), 'User'), ), Optional( 'username', UniqueField( 'username', lambda username: user_dao.find_by(username=username), 'User', ), ), moh_validator, ], edit=[ Optional('email', UniqueFieldChanged('email', user_dao.find_by, 'User')), Optional('username', UniqueFieldChanged('username', user_dao.find_by, 'User')), moh_validator, ], )
def build_validator(): return ValidationGroup( delete=[NoVoicemailAssociated(), NoLineAssociated(user_line_dao)], create=[ Optional( 'email', UniqueField('email', lambda email: user_dao.find_by(email=email), 'User'), ), Optional( 'username', UniqueField( 'username', lambda username: user_dao.find_by(username=username), 'User', ), ), ], edit=[ Optional('email', UniqueFieldChanged('email', user_dao, 'User')), Optional('username', UniqueFieldChanged('username', user_dao, 'User')), ], )
def build_validator(registrar_dao): return ValidationGroup( create=[ Optional('provisioning_code', ProvCodeAvailable(line_dao)), Optional('registrar', GetResource('registrar', registrar_dao.get, 'Registrar')), GetResource('context', context_dao.get_by_name, 'Context'), ], edit=[ ProvCodeChanged(line_dao), GetResource('registrar', registrar_dao.get, 'Registrar'), GetResource('context', context_dao.get_by_name, 'Context'), ], )
def build_validator(): return ValidationGroup( create=[ Optional( 'name', UniqueField('name', lambda value: iax_dao.find_by(name=value), 'IAXEndpoint'), ) ], edit=[ Optional('name', UniqueFieldChanged('name', iax_dao, 'IAXEndpoint')) ], )
def build_validator(): return ValidationGroup( create=[ Optional( 'name', UniqueField('name', lambda v: sip_dao.find_by(name=v), 'SIPEndpoint'), ) ], edit=[ Optional('name', UniqueFieldChanged('name', sip_dao, 'SIPEndpoint')) ], )
def build_validator_forward(): return ValidationGroup(edit=[ Optional( 'busy_enabled', NoEmptyFieldWhenEnabled('busy_destination', 'busy_enabled'), ), Optional( 'noanswer_enabled', NoEmptyFieldWhenEnabled('noanswer_destination', 'noanswer_enabled'), ), Optional( 'unconditional_enabled', NoEmptyFieldWhenEnabled('unconditional_destination', 'unconditional_enabled'), ), ])
def build_validator(): return ValidationGroup( create=[ Optional( 'context', GetResource('context', context_dao_module.get_by_name, 'Context'), ), ContextTenantValidator(context_dao_module), ], edit=[ Optional( 'context', GetResource('context', context_dao_module.get_by_name, 'Context'), ), ContextTenantValidator(context_dao_module), ], )
def build_validator(): return ValidationGroup( create=[ UniqueField( 'name', lambda name: call_pickup_dao.find_by(name=name), 'CallPickup' ) ], edit=[ Optional('name', UniqueFieldChanged('name', call_pickup_dao, 'CallPickup')) ], )
def test_given_multiple_validators_for_field_then_all_validators_called( self): child_validator1 = Mock() child_validator2 = Mock() model = Mock(field='field') validator = Optional('field', child_validator1, child_validator2) validator.validate(model) child_validator1.validate.assert_called_once_with(model) child_validator2.validate.assert_called_once_with(model)
def build_validator(): return ValidationGroup( create=[ UniqueField('number', lambda number: agent_dao.find_by(number=number), 'Agent') ], edit=[ Optional('number', UniqueFieldChanged('number', agent_dao, 'Agent')) ], )
def build_validator(): return ValidationGroup( create=[ UniqueField('name', lambda name: group_dao.find_by(name=name), 'Group'), GroupValidator(), ], edit=[ Optional('name', UniqueFieldChanged('name', group_dao, 'Group')), GroupValidator(), ], )
def build_validator(): return ValidationGroup( create=[ UniqueField('name', lambda name: queue_dao.find_by(name=name), 'Queue'), QueueValidator(), ], edit=[ Optional('name', UniqueFieldChanged('name', queue_dao, 'Queue')), QueueValidator(), ], )
def build_validator(device_dao, line_dao): return ValidationGroup( common=[ Optional( 'plugin', MemberOfSequence('plugin', device_dao.plugins, 'Plugin') ), Optional( 'template_id', MemberOfSequence( 'template_id', device_dao.device_templates, 'DeviceTemplate' ), ), ], create=[ Optional( 'mac', UniqueField('mac', lambda mac: device_dao.find_by(mac=mac), 'Device'), ) ], edit=[Optional('mac', UniqueFieldChanged('mac', device_dao.find_by, 'Device'))], delete=[DeviceNotAssociated(line_dao)], )
def build_validator(): return ValidationGroup( create=[ UniqueField('number', lambda number: paging_dao.find_by(number=number), 'Paging') ], edit=[ Optional( 'number', UniqueFieldChanged('number', paging_dao.find_by, 'Paging')) ], )
def build_validator(): return ValidationGroup( common=[ GetResource('context', context_dao.get_by_name, 'Context'), Optional( 'timezone', MemberOfSequence('timezone', static_voicemail.find_all_timezone, 'Timezone'), ), ], create=[NumberContextExists(voicemail_dao)], edit=[NumberContextChanged(voicemail_dao)], delete=[AssociatedToUser()], )
def build_validator(): return ValidationGroup( create=[ UniqueField('name', lambda name: call_filter_dao.find_by(name=name), 'CallFilter') ], edit=[ Optional( 'name', UniqueFieldChanged('name', call_filter_dao.find_by, 'CallFilter'), ) ], )
def build_validator(): moh_validator = MOHExists('music_on_hold', moh_dao.get_by) return ValidationGroup( create=[ UniqueField('name', lambda name: queue_dao.find_by(name=name), 'Queue'), QueueValidator(), WaitDestinationValidator(), moh_validator, ], edit=[ Optional('name', UniqueFieldChanged('name', queue_dao.find_by, 'Queue')), QueueValidator(), WaitDestinationValidator(), moh_validator, ], )
def build_validator(pjsip_doc): sip_find_by = partial(sip_dao_module.find_by, template=False) template_find_by = partial(sip_dao_module.find_by, template=True) return ValidationGroup( create=[ Optional( 'name', UniqueField('name', lambda v: sip_find_by(name=v), 'SIPEndpoint'), UniqueField('name', lambda v: template_find_by(name=v), 'SIPEndpointTemplate'), UniqueField('name', lambda v: transport_dao.find_by(name=v), 'Transport'), ), Optional( 'aor_section_options', PJSIPDocValidator('aor_section_options', 'aor', pjsip_doc), ), Optional( 'auth_section_options', PJSIPDocValidator('auth_section_options', 'auth', pjsip_doc), ), Optional( 'endpoint_section_options', PJSIPDocValidator('endpoint_section_options', 'endpoint', pjsip_doc), ), Optional( 'identify_section_options', PJSIPDocValidator('identify_section_options', 'identify', pjsip_doc), ), Optional( 'registration_section_options', PJSIPDocValidator('registration_section_options', 'registration', pjsip_doc), ), Optional( 'registration_outbound_auth_section_options', PJSIPDocValidator('registration_outbound_auth_section_options', 'auth', pjsip_doc), ), Optional( 'outbound_auth_section_options', PJSIPDocValidator('outbound_auth_section_options', 'auth', pjsip_doc), ), ], edit=[ EndpointSIPTemplatesValidator(), Optional( 'name', UniqueFieldChanged('name', sip_find_by, 'SIPEndpoint', id_field='uuid'), UniqueFieldChanged('name', template_find_by, 'SIPEndpointTemplate', id_field='uuid'), UniqueFieldChanged('name', transport_dao.find_by, 'Transport', id_field='uuid'), ), Optional( 'aor_section_options', PJSIPDocValidator('aor_section_options', 'aor', pjsip_doc), ), Optional( 'auth_section_options', PJSIPDocValidator('auth_section_options', 'auth', pjsip_doc), ), Optional( 'endpoint_section_options', PJSIPDocValidator('endpoint_section_options', 'endpoint', pjsip_doc), ), Optional( 'identify_section_options', PJSIPDocValidator('identify_section_options', 'identify', pjsip_doc), ), Optional( 'registration_section_options', PJSIPDocValidator('registration_section_options', 'registration', pjsip_doc), ), Optional( 'registration_outbound_auth_section_options', PJSIPDocValidator('registration_outbound_auth_section_options', 'auth', pjsip_doc), ), Optional( 'outbound_auth_section_options', PJSIPDocValidator('outbound_auth_section_options', 'auth', pjsip_doc), ), ], )
def setUp(self): self.child_validator = Mock(Validator) self.validator = Optional('field', self.child_validator)