2 require_once("AOOSInterfaces.php");
4 class LengthConstraint
implements AOOSModelConstraintInterface
{
5 static public function name() {
9 static public function numArgs() {
13 static public function check($args, $value) {
14 if (is_integer($value) ||
is_object($value) ||
is_float($value) ||
is_bool($value)) {
20 static public function execute($args, $value) {
22 if (is_string($value)) {
23 if (strlen($value) > $length) {
24 return substr($value, 0, $length);
30 elseif (is_array($value)) {
31 if (count($value) > $length) {
32 return array_slice($value, 0, $length);
42 class MatchConstraint
implements AOOSModelConstraintInterface
{
43 static public function name() {
47 static public function numArgs() {
51 static public function check($args, $value) {
52 if (!is_string($value)) {
58 static public function execute($args, $value) {
60 if (preg_match($pattern, $value)) {
67 class RangeConstraint
implements AOOSModelConstraintInterface
{
68 static public function name() {
72 static public function numArgs() {
76 static public function check($args, $value) {
79 if (!is_integer($value) && !is_float($value)) {
82 if (!(is_integer($start) ||
is_float($start) ||
is_integer($end) ||
is_float($end)) ||
$start > $end) {
88 static public function execute($args, $value) {
91 if ($value < $start) {
94 elseif ($value > $end) {