<commit_before>from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask_validator import ValidateInteger, ValidateString

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
db = SQLAlchemy(app)


class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    string = db.Column(db.String(80))
    integer = db.Column(db.Integer())

    def __init__(self, string, integer):
        self.string = string
        self.integer = integer

    @classmethod
    def __declare_last__(cls):
        ValidateInteger(User.integer)
        ValidateString(User.string, False, True, "Custom Message")

db.create_all()
u = User("user", 1)
db.session.add(u)
db.session.commit()<commit_msg>Example edited with custom messages<commit_after>from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask_validator import ValidateInteger, ValidateString

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
db = SQLAlchemy(app)


class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    string = db.Column(db.String(80))
    integer = db.Column(db.Integer())

    def __init__(self, string, integer):
        self.string = string
        self.integer = integer

    @classmethod
    def __declare_last__(cls):
        ValidateInteger(User.integer)
        ValidateString(User.string, False, True, "Custom Message, "
                                                 "Field {field} - Value {value} - Oldvalue {oldvalue} - Key {key}")

db.create_all()
u = User("user", 1)
db.session.add(u)
db.session.commit()
{'fraction_non_alphanumeric': 0.12208258527827648, 'fraction_numerical': 0.003590664272890485, 'mean_word_length': 3.5311653116531163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4076582', 'n_tokens_mistral': 541, 'n_tokens_neox': 527, 'n_words': 117}