This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Regex = TSValidate.Validators.Regex; | |
validator.add('created_at', new Regex() | |
.pattern(/^[0-9]{4}[-\/](0[1-9]|1[12])[-\/](0[1-9]|[12][0-9]|3[01])$/) | |
.message('The creation date is invalid') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import InclusionIn = TSValidate.Validators.InclusionIn; | |
validator.add('status', new InclusionIn() | |
.message('The status must be A or B') | |
.domain(['A', 'B']) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ExclusionIn = TSValidate.Validators.ExclusionIn; | |
validator.add('status', new ExclusionIn() | |
.message('The status must not be A or B') | |
.domain(['A', 'B']) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Email = TSValidate.Validators.Email; | |
validate.add('email', new Email() | |
.message('The e-mail is not valid') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Identical = TSValidate.Validators.Identical; | |
validator.add('terms', new Identical() | |
.accepted('yes') | |
.message('Terms and conditions must be accepted') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PresenceOf = TSValidation.Validators.PresenceOf; | |
validator.add('name', new PresenceOf() | |
.message('The name is required') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Email = TSValidate.Validators.Email; | |
import PresenceOf = TSValidate.Validators.PresenceOf; | |
var validation = new TSValidate.Validation; | |
validation.add( | |
'name', | |
new PresenceOf() | |
.message('The name is required') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Acl\Adapter; | |
use PhalconRest\Acl\MountingEnabledAdapterInterface; | |
class Memory extends \Phalcon\Acl\Adapter\Memory implements MountingEnabledAdapterInterface | |
{ | |
use \AclAdapterMountTrait; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var \PhalconRest\Acl\MountingEnabledAdapterInterface $acl */ | |
$acl = $di->get(Services::ACL); | |
// These are our main roles | |
$unauthorizedRole = new Acl\Role(AclRoles::UNAUTHORIZED); | |
$authorizedRole = new Acl\Role(AclRoles::AUTHORIZED); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$api->resource(Resource::crud('/users', 'User') | |
// Here we restrict access to all endpoints | |
// on this Resource. The `User` role is not allowed | |
// to access all endpoints by default. | |
->deny(AclRoles::UNAUTHORIZED, AclRoles::USER) | |
// Because access can be overridden, |