Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attribute validator #6

Open
marcelsud opened this issue Jan 23, 2014 · 0 comments
Open

Add attribute validator #6

marcelsud opened this issue Jan 23, 2014 · 0 comments
Milestone

Comments

@marcelsud
Copy link
Contributor

Implement attribute validator for objects, such as:

class Customer
{
    public $name;
    public $email;
    public $address;
}

class Address
{
    public $street;
    public $number;
}

$customer = new Customer();
$customer->name = "John Doe";
$customer->email = "[email protected]";
$customer->address = new Address();
$customer->address->street = "Lorem ipsum dolor";
$customer->address->number= 123;

$customerValidator = v::attr("name", v::string()->minLength(5));
$customerValidator->attr("email", v::email());
$customerValidator->attr("address", v::attr("street", v::string())->attr("number", v::int()));

$customerValidator->validate($customer); //true
@marcelsud marcelsud removed the ready label Jan 4, 2015
@marcelsud marcelsud added this to the v1.2.0 milestone Jan 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant