DavidePastore / Slim-Validation

A validation library for the Slim Framework. It internally uses Respect/Validation.
170 stars 30 forks source link

Validate string #44

Closed victorLessa closed 5 years ago

victorLessa commented 5 years ago

Is there any function String ()?

My code..

$name = v::string()->noWhitespace()->length(1, 10);
$ageValidator = v::numeric()->positive()->between(1, 20);
$date = v::numeric()->positive()->length(1, 8);
$employee = v::numeric()->positive()->length(1, 1);
$validators = array(
  'first_name' => $name,
  'last_name' => $name,
  'date_Of_Birth' => $date,
  'employee' => $employee,
  'age' => $ageValidator
);

$app->add(new \DavidePastore\Slim\Validation\Validation($validators));
DavidePastore commented 5 years ago

Hi @VictorLessa . Yes, if you want to check if the given variable is a string, you can use the v::stringType validator. Let me know if you have additional related questions.