6#include "validatorafter_p.h"
16 const char *inputFormat,
20 *new ValidatorAfterPrivate(field, comparison, timeZone, inputFormat, messages, defValKey))
36 const QTimeZone tz = d->extractTimeZone(c, params, d->timeZone);
40 ? d->extractOtherDateTime(c, params, d->comparison.toString(), tz, d->inputFormat)
46 if (Q_UNLIKELY(!odate.
isValid())) {
47 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid comparison date";
50 const QDate date = d->extractDate(c, v, d->inputFormat);
51 if (Q_UNLIKELY(!date.
isValid())) {
52 qCWarning(C_VALIDATOR).noquote().nospace()
53 <<
debugString(c) <<
" Can not parse input date \"" << v <<
"\"";
56 if (Q_UNLIKELY(date <= odate)) {
57 qCDebug(C_VALIDATOR).noquote()
58 <<
debugString(c) <<
"Input" << date <<
"is not after" << odate;
69 if (Q_UNLIKELY(!odatetime.
isValid())) {
70 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid comparison datetime";
73 const QDateTime datetime = d->extractDateTime(c, v, d->inputFormat, tz);
74 if (Q_UNLIKELY(!datetime.
isValid())) {
75 qCWarning(C_VALIDATOR).noquote().nospace()
76 <<
debugString(c) <<
" Can not parse input datetime \"" << v <<
"\"";
79 if (Q_UNLIKELY(datetime <= odatetime)) {
80 qCDebug(C_VALIDATOR).noquote()
81 <<
debugString(c) <<
"Input" << datetime <<
"is not after" << odatetime;
92 if (Q_UNLIKELY(!otime.
isValid())) {
93 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid comparison time";
96 const QTime time = d->extractTime(c, v, d->inputFormat);
97 if (Q_UNLIKELY(!time.
isValid())) {
98 qCWarning(C_VALIDATOR).noquote().nospace()
99 <<
debugString(c) <<
" Can not parse input time \"" << v <<
"\"";
102 if (Q_UNLIKELY(time <= otime)) {
103 qCDebug(C_VALIDATOR).noquote()
104 <<
debugString(c) <<
"Input" << time <<
"is not after" << otime;
113 qCWarning(C_VALIDATOR).noquote()
114 <<
debugString(c) <<
"Invalid comparison data:" << d->comparison;
134 return c->
qtTrId(
"cutelyst-valafter-genvalerr-date")
139 return c->
qtTrId(
"cutelyst-valafter-genvalerr-dt")
144 return c->
qtTrId(
"cutelyst-valafter-genvalerr-time")
156 return c->
qtTrId(
"cutelyst-valafter-genvalerr-date-label")
162 return c->
qtTrId(
"cutelyst-valafter-genvalerr-dt-label")
167 return c->
qtTrId(
"cutelyst-valafter-genvalerr-time-label")
181 return c->
qtTrId(
"cutelyst-validator-genvaldataerr-dt");
186 return c->
qtTrId(
"cutelyst-validator-genvaldataerr-dt-label").
arg(_label);
195 if (d->inputFormat) {
196 const QString _inputFormatTranslated =
197 d->translationContext ? c->
translate(d->translationContext, d->inputFormat)
198 : c->
qtTrId(d->inputFormat);
202 return c->
qtTrId(
"cutelyst-validator-genparseerr-dt-format")
203 .
arg(_inputFormatTranslated);
208 return c->
qtTrId(
"cutelyst-validator-genparseerr-dt-format-label")
209 .
arg(_label, _inputFormatTranslated);
217 return c->
qtTrId(
"cutelyst-validator-genparseerr-dt");
220 return c->
qtTrId(
"cutelyst-validator-genparseerr-time");
223 return c->
qtTrId(
"cutelyst-validator-genparseerr-date");
232 return c->
qtTrId(
"cutelyst-vaidator-genparseerr-dt-label").
arg(_label);
236 return c->
qtTrId(
"cutelyst-validator-genparseerr-time-label").
arg(_label);
240 return c->
qtTrId(
"cutelyst-validator-genparseerr-date-label").
arg(_label);
QLocale locale() const noexcept
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
QString qtTrId(const char *id, int n=-1) const
Checks if a date, time or datetime is after a comparison value.
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
ValidatorAfter(const QString &field, const QVariant &comparison, const QString &timeZone=QString(), const char *inputFormat=nullptr, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
~ValidatorAfter() override
QString genericValidationDataError(Context *c, const QVariant &errorData=QVariant()) const override
QString genericParsingError(Context *c, const QVariant &errorData=QVariant()) const override
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Base class for all validator rules.
QString validationError(Context *c, const QVariant &errorData={}) const
QString label(Context *c) const
QString validationDataError(Context *c, const QVariant &errorData={}) const
void defaultValue(Context *c, ValidatorReturnType *result) const
QString value(const ParamsMultiMap ¶ms) const
QString parsingError(Context *c, const QVariant &errorData={}) const
QString debugString(Context *c) const
The Cutelyst namespace holds all public Cutelyst API.
bool isValid(int year, int month, int day)
bool isValid() const const
QString toString(QDate date, QLocale::FormatType format) const const
QString arg(Args &&... args) const const
bool isEmpty() const const
bool isValid(int h, int m, int s, int ms)
void setValue(QVariant &&value)
QDate toDate() const const
QDateTime toDateTime() const const
QTime toTime() const const
int userType() const const
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.