def validate(self, value): if not isinstance(value, datetime.date): try: value = datetime.datetime.strptime(value, '%Y-%m-%d').date() except ValueError: raise ValidationError( "Datetime should be formatted as YYYY-MM-DD") dt = datetime.date.today() if value >= dt: raise ValidationError("Date is not at the past") return True
def validate(self, value): if value is None or value == "": return True staff = db["Staff"] member = staff.fetchFirstExample({'_key': str(value)}) if not member: raise ValidationError("Doctor ID doesn't exist") else: member = member[0] if member["designation"] != "doctor": raise ValidationError("Doctor ID doesn't exist") return True
def validate(self, value): patients = db["Patients"] patient = patients.fetchFirstExample({'_key': str(value)}) if not patient: raise ValidationError("Patient ID doesn't exist") return True
def validate(self, value): if not isinstance(value, list): raise ValidationError("Not a list") if len(value) == 0: raise ValidationError("Empty list") for q in value: if "question" not in q or "answer" not in q: raise ValidationError("Bad object format") if q["question"] == "": raise ValidationError("Empty question") if q["answer"] == "": raise ValidationError("Empty answer") return True
def validate(self, value): staff = db["Staff"] query = staff.fetchByExample({'email': value}, batchSize=1, count=True) if query.count != 0: raise ValidationError( "This email is already registered in the system") return True
def validate(self, value): if value is None or value == "": return True staff = db["Staff"] member = staff.fetchFirstExample({'_key': str(value)}) if not member: raise ValidationError("Staff ID doesn't exist") return True
def validate(self, value): if value == "" or value is None: return True if not isinstance(value, datetime.date): try: datetime.datetime.strptime(value, '%Y-%m-%d') except ValueError: raise ValidationError( "Datetime should be formatted as YYYY-MM-DD. Current: " + value) return True
def validate(self, value): for field in self.required_fields: if field not in value: raise ValidationError(field.capitalize(), 'is missing')
def validate(self, value): if search('\d\d\d-\d\d-\d\d\d\d', value) is None: raise ValidationError('SSN should be formatted as 123-45-6789')
def validate(self, value): if type(value) is not str: raise ValidationError("Field value must be a String") return True
def validate(self, value): if value is not True or False: raise ValidationError("Field value must be a Boolean") return True
def validate(self, value): if value is not "Owner" or 'Participant': raise ValidationError("Field value must be a Owner/Participant") return True
def validate(self, value): if type(value) is not int: raise ValidationError("Field value must be a Integer") return True