def validate_names(self, value): for name in value: StartDateEndDateValidator('start_date', 'end_date')(name) if len(value) == 0: raise serializers.ValidationError( _("Agents requires at least one name")) return value
class Meta(AccessAidSerializer.Meta): fields = ('name', 'type', 'description', 'start_date', 'end_date', 'security_level', 'link') validators = [ StartDateEndDateValidator( start_date='start_date', end_date='end_date', ) ]
class Meta(AgentSerializer.Meta): extra_kwargs = { 'create_date': { 'default': timezone.now, }, } validators = [ StartDateEndDateValidator( start_date='start_date', end_date='end_date', ) ]
class Meta(StructureSerializer.Meta): fields = StructureSerializer.Meta.fields + ('version_link',) validators = [ StartDateEndDateValidator( start_date='start_date', end_date='end_date', ), ] extra_kwargs = { 'is_template': {'read_only': True}, 'template': {'read_only': True}, 'version': { 'default': '1.0', } }