문제

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.

도움이 되었습니까?

해결책

Try this:

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

Demo here

다른 팁

Try This:

validates :version, format: { with: /^([\d\.]+)/,message: "Version must be x.x format." }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top