Giter Site home page Giter Site logo

hotta / peewee-validates Goto Github PK

View Code? Open in Web Editor NEW

This project forked from timster/peewee-validates

0.0 1.0 0.0 115 KB

A simple and flexible model and data validator for Peewee ORM.

Home Page: https://peewee-validates.readthedocs.io

License: MIT License

Python 98.57% Makefile 1.43%

peewee-validates's Introduction

peewee-validates

Peewee ORM のための、シンプルかつフレキシブルなモデルとデータバリデータ。

Build Status Code Coverage Version Downloads Documentation

必要事項

  • python >= 3.3
  • peewee >= 2.8.2 (including Peewee 3)
  • python-dateutil >= 2.5.0

インストール

このパッケージは pip でインストールできます:

pip install peewee-validates

使い方

peewee-validates でできることを以下にチラ見せします:

import peewee
from peewee_validates import ModelValidator

class Category(peewee.Model):
    code = peewee.IntegerField(unique=True)
    name = peewee.CharField(null=False, max_length=250)

obj = Category(code=42)

validator = ModelValidator(obj)
validator.validate()

print(validator.errors)

# {'name': 'This field is required.', 'code': 'Must be a unique value.'}

実際のところ、モデルさえ必要としない汎用的なバリデータもあります:

from peewee_validates import Validator, StringField

class SimpleValidator(Validator):
    name = StringField(required=True, max_length=250)
    code = StringField(required=True, max_length=4)

validator = SimpleValidator(obj)
validator.validate({'code': 'toolong'})

print(validator.errors)

# {'name': 'This field is required.', 'code': 'Must be at most 5 characters.'}

ドキュメント

詳細は 完全なドキュメント を参照してください。

日本語ドキュメントは https://net-newbie.com/peewee-validates/ にあります。

peewee-validates's People

Contributors

timster avatar nad2000 avatar ossbn-mhotta avatar cscps avatar sabinem avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.