Skip to content

Instantly share code, notes, and snippets.

@baldurrensch
Created August 15, 2012 21:21
Show Gist options
  • Save baldurrensch/3363772 to your computer and use it in GitHub Desktop.
Save baldurrensch/3363772 to your computer and use it in GitHub Desktop.
Credit Card Validation
Acme\DV2Bundle\Model\CreditCard:
properties:
creditCardNumber:
- NotBlank: { groups: [flow_checkoutForm_step2]}
- MinLength: {limit: 15, groups: [flow_checkoutForm_step2]}
- MaxLength: {limit: 16, groups: [flow_checkoutForm_step2]}
creditCardCVV:
- NotBlank: { groups: [flow_checkoutForm_step2]}
- Regex: { pattern: "/^\d{3,4}$/", message: "Invalid CVV code", groups: [flow_checkoutForm_step2] }
getters:
validCCExpiration:
- "True": { message: "The credit card is expired", groups: [flow_checkoutForm_step2] }
validCreditCard:
- "True": {message: "The credit card number is invalid", groups: [flow_checkoutForm_step2] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment