Skip to content

MindaugasN/database-field-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

We want to define classes that have fields that we want validated before we can set their value.

Objects will later be serialized into a database, and we need to ensure the data is valid before we write to the database.

IntegerField

  • Only allows integral numbers;
  • Has minimum value;
  • Has maximum value;

CharField

  • Only allows strings;
  • Has minimum length;
  • Has maximum length;

Expected usage

class Person:
    name = CharField(1, 50)
    age = IntegerField(0, 200)

Project structure

project
|-- model
    |-- __init__.py
    |-- base.py
    |-- fields
        |-- char.py
        |-- integer.py    
|-- tests
    |-- __init__.py
    |-- unit
        |-- test_integer_field.py
        |-- test_char_field.py
|-- README.md
|-- .gitignore

Running tests

python -m unittest tests.unit.test_integer_field -v
python -m unittest tests.unit.test_char_field -v

About

Objects, which will be later serialized into database, validations. We want to make sure we store data in valid data types using data descriptors.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages