Unsure if I’ve missed it, but the custom User Fields, you can set a field type, bu is their anyway to verify on these fields, such as for a mobile number or via regex so we can verify against any data?
If not currently, could this be added?
Unsure if I’ve missed it, but the custom User Fields, you can set a field type, bu is their anyway to verify on these fields, such as for a mobile number or via regex so we can verify against any data?
If not currently, could this be added?
There isn’t much point in adding phone number verification. It’s easy for a bad actor to generate a bogus phone number with the right number of digits and highly annoying when a legitimate user has to guess what phone number format someone thinks is the right one.
That was just an example of one field, we have multiple fields to store such as memberships. And it we need some sort of verification that the information is even remotely correct. Currently for a phone number you can enter text.
We should be able to use regex to verify these fields or they are pretty useless.
Also, on the point of mobile numbers, yes they can be fake, but for our use case of the forum, its for their benefit that is correct. And being able to perform some sort of verification means that our scripts that would use them wouldn’t be affected by entering letters instead of numbers for example.
One the second point of different formats, that easy enough where you give the field a description field so you can let them know that. Verification of custom fields is a very basic requirement.
If you want that kind of detail consider an external membership platform and IdM.
This isn’t the kind of thing that discussion software should be doing.
Again, the point isn’t what I want to do with it, but more the fact that custom fields should be able to be verified.
There is no point in them if you can’t somehow verify the data going into them.
How much do you verify the name and identity of your users?
A lot, we’re a closed community. We are only able to verify on email at the moment compared to our current system, but as this can change on both sides, we want them to be able to enter a membership number and mobile and verify on both of those as well. At least if the verification of the field allows us to ensure the info entered is of the right type and length, our scripts using the API can handle the rest.
So you’re not talking about verifying anything, just validating that the data meets an expected format.
Discourse isn’t going to do this for you, you might be able to achieve validation with a plugin, but even then there’s nothing to prevent someone entering bad data in an expected format just to bypass said validation.
Your only real option is to look at something off-site or create a genuine incentive for users to provide real data. Right now you’re fixating on a symptom (not getting the data you want), not the root of the problem (giving users a real and compelling reason to provide it).
バリデーション機能があると非常に助かります。特に電話番号の場合、先頭の「+」の扱いでうまく入力できない人が多いためです。確かにデータベースを整理することもできますが、それは非常に手間がかかります。
完全に同意します。フィールドの形式や文字数に基づく検証が可能であれば、さらに正規表現での一致も許容すれば、そのフィールドに期待通りのデータ型が来ていることが保証され、API スクリプトがエラーなく処理できるようになります。
この件については遅くなってしまい申し訳ありません。カスタムフィールドのバリデーション方法を探して Meta を検索している方のために、プラグインを使ってどう行うかをご紹介しておきます。
plugin.rb で、User に対して validate メソッドを使用します。その後、カスタムフィールドを確認し、無効なものがあればエラーを設定できます。
require_dependency 'user'
validate User, :my_cool_validation_method do
field = self.custom_fields['cool_tapes']
if ! field.blank? && field.include?("bag of four grapes")
self.errors[:cool_tapes] << "No rhymes allowed."
end
end
注::my_cool_validation_method というシンボルは任意の名前で構いませんが、User モデルのコンテキスト内では一意である必要があります。
サインアップ時やユーザープロフィールの編集時に、ユーザーのカスタムフィールドを検証するためにこれを使用できますか?
また、これをテーマコンポーネントに配置することはできますか?