::addRequiredRule()public

Requires that a column have a non-NULL value

Before using this method, try setting the database column to NOT NULL and remove any default value. Such a configuration will trigger the same functionality as this method, and will enforce the rule on the database level for any other code that queries it.

::addStringReplacement()public

String replacement is done after the post::validate() hook, and right before the messages are reordered.

If a message is an empty string after replacement, it will be removed from the list of messages.

Signature

voidaddStringReplacement(mixed$class,string$search,string$replace)

Parameters

mixed

$class

The class name or instance of the class the columns exists in

string

$search

The string to search for

string

$replace

The string to replace with

::addValidValuesRule()public

Restricts a column to having only a value from the list of valid values

Please note that NULL values are always allowed, even if not listed in the $valid_values array, if the column is not set as NOT NULL.

This functionality can also be accomplished by added a CHECK constraint on the column in the database, or using a MySQL ENUM data type.

Signature

voidaddValidValuesRule(mixed$class,string$column,array$valid_values)

Parameters

mixed

$class

The class name or instance of the class this rule applies to

string

$column

The column to validate

array

$valid_values

The valid values to check - NULL values are always allows if the column is not set to NOT NULL

::hasValue()internal public

Please note: this method is public, however it is
primarily intended for internal use by Flourish and will normally not
be useful in site/application code

Checks to see if a columns has a value, but based on the schema and if the column allows NULL

If the columns allows NULL values, than anything other than NULL will be returned as TRUE. If the column does not allow NULL and the value is anything other than the "empty" value for that data type, then TRUE will be returned.

The values that are considered "empty" for each data type are as follows. Please note that there is no "empty" value for dates, times or timestamps.