In PostgreSQL Validator does not work when input a string of numbers only, such as 001206

In PostgreSQL Validator does not work when input a string of numbers only, such as 001206

mac129mac129 Posts: 6Questions: 2Answers: 0

First of all, thank you very much Allan for answering my question!
https://datatables.net/forums/discussion/74619/postgressql-can-not-input-decimal-type#Comment_214551
This solved the problem of displaying decimals, but something new was bothering me. I set a field to display the number-only code, which starts with a 0, such as 001206. In the Database, here's the setting.

If this field is set to int, the preceding 0 will not be displayed, like 1206 instead of 001206
it is I can accomplish inputting that number-only string when the code in my Controller and Model looks like this.

                    .Field(new Field("office")
                        .DbType(System.Data.DbType.AnsiString)
                    )
 public string office { get; set; }

And the results are shown below.


But when I added Validator like this ↓, I encountered an error: 42883: operator does not exist: text = integer,
And this error occurs only when all the input is numeric characters.

                .Field(new Field("office")
                        .Validator(Validation.Unique(new ValidationOpts
                        {
                            Message = "Please enter a unique code"
                        }))
                        .DbType(System.Data.DbType.AnsiString)
                    )

How to set parameters to make the Validator function work properly?
Thanks for your help!

Sign In or Register to comment.