Pregunta

validates :version, format: { with: /\d+\.\d+/,message: "Version must be x.x format." }

this allow like v 1.1 and v 1.1.1

but i want it allow only 1.1, 1.1.1, 1.2.3 etc, Only decimal and number i want to allow.

¿Fue útil?

Solución

Try this:

^\d.\d(\.\d)?$

Demo here

Otros consejos

Try This:

validates :version, format: { with: /^([\d\.]+)/,message: "Version must be x.x format." }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top