0

I work with symfony4.
I would add same validation to my input number to accept only values like :

1
10
100
1000
10000
100000
1000000
1
  • Regex: 10{0,6} Commented Mar 16, 2018 at 12:06

4 Answers 4

1

You have to use Choice validation. All info about choice validation You can find here

Sign up to request clarification or add additional context in comments.

Comments

1

You can use regex with this pattern

"/^1+0*/"

Example

class MyClass
{
    /**
     * @Assert\Regex(
     *     pattern     = "/^1+0*/",
     *     message="Wrong number"
     * )
     */
    protected $myNumber;
}

Comments

1

You can use regex with this pattern

"/^1[0]*$/"

Demo: https://regex101.com/r/eSnOfp/1

Comments

0

I solved it by this pattern :

pattern="[0-1]+"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.