Skip to content

Commit

Permalink
Added Some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aitboudad committed Apr 21, 2013
1 parent d79e7df commit 0591adf
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions reference/constraints/Isbn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ on an object that will contain a ISBN number.

.. code-block:: yaml
# src/Acme/DemoBundle/Resources/config/validation.yml
Acme\DemoBundle\Entity\AcmeEntity:
# src/Acme/BookcaseBunlde/Resources/config/validation.yml
Acme\BookcaseBunlde\Entity\Book:
properties:
isbn:
- Isbn:
Expand All @@ -39,8 +39,8 @@ on an object that will contain a ISBN number.
.. code-block:: xml
<!-- src/Acme/DemoBundle/Resources/config/validation.xml -->
<class name="Acme\DemoBundle\Entity\AcmeEntity">
<!-- src/Acme/BookcaseBunlde/Resources/config/validation.xml -->
<class name="Acme\BookcaseBunlde\Entity\Book">
<property name="isbn">
<constraint name="Isbn">
<option name="isbn10">true</option>
Expand All @@ -52,10 +52,10 @@ on an object that will contain a ISBN number.
.. code-block:: php-annotations
// src/Acme/DemoBundle/Entity/AcmeEntity.php
// src/Acme/BookcaseBunlde/Entity/Book.php
use Symfony\Component\Validator\Constraints as Assert;
class AcmeEntity
class Book
{
/**
* @Assert\Isbn(
Expand All @@ -69,17 +69,19 @@ on an object that will contain a ISBN number.
.. code-block:: php
// src/Acme/DemoBundle/Entity/AcmeEntity.php
// src/Acme/BookcaseBunlde/Entity/Book.php
namespace Acme\BookcaseBunlde\Entity;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\Isbn;
use Symfony\Component\Validator\Constraints as Assert;
class AcmeEntity
class Book
{
protected $isbn;
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('isbn', new Isbn(array(
$metadata->addPropertyConstraint('isbn', new Assert\Isbn(array(
'isbn10' => true,
'isbn13' => true,
'bothIsbnMessage' => 'This value is neither a valid ISBN-10 nor a valid ISBN-13.'
Expand Down Expand Up @@ -128,4 +130,4 @@ isbn13
**type**: ``boolean`` [:ref:`default option<validation-default-option>`]

If this required option is set to ``true`` the constraint will check
if the code is a valid ISBN-13 code.
if the code is a valid ISBN-13 code.

0 comments on commit 0591adf

Please sign in to comment.