21#ifndef KICAD_PROPERTY_VALIDATORS_H
22#define KICAD_PROPERTY_VALIDATORS_H
50 return wxString::Format( wxS(
"Value must be less than or equal to %s" ),
73 return wxString::Format( wxS(
"Value must be greater than or equal to %s" ),
104 template<
int Min,
int Max>
107 wxASSERT_MSG( aValue.CheckType<
int>(),
"Expecting int-containing value" );
109 int val = aValue.As<
int>();
112 return std::make_unique<VALIDATION_ERROR_TOO_LARGE<int>>( val, Max );
114 return std::make_unique<VALIDATION_ERROR_TOO_SMALL<int>>( val, Min );
121 wxASSERT_MSG( aValue.CheckType<
int>(),
"Expecting int-containing value" );
123 int val = aValue.As<
int>();
126 return std::make_unique<VALIDATION_ERROR_TOO_SMALL<int>>( val, 0 );
A base class for most all the KiCad significant classes used in schematics and boards.
A set of generic validators.
static VALIDATOR_RESULT PositiveIntValidator(const wxAny &&aValue, EDA_ITEM *aItem)
static VALIDATOR_RESULT RangeIntValidator(const wxAny &&aValue, EDA_ITEM *aItem)
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Converts aValue in internal units into a united string.
A validator for use when you just need to return an error string rather than also packaging some othe...
wxString Format(UNITS_PROVIDER *aUnits) const override
VALIDATION_ERROR_MSG(const wxString &aMessage)
wxString Format(UNITS_PROVIDER *aUnits) const override
VALIDATION_ERROR_TOO_LARGE(T aActual, T aMaximum, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
VALIDATION_ERROR_TOO_SMALL(T aActual, T aMinimum, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
wxString Format(UNITS_PROVIDER *aUnits) const override
Represents an error returned by a validator and contains enough data to format an error message.
EDA_DATA_TYPE
The type of unit.
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.