I have the following JSON:
validate = {
'(\\.org|\\.info|\\.biz|\\.name)$': [
{ 'type': 'size', 'pattern': /^.{3,64}$/, 'error': 'Your domain can have at max 26 characters and at least 3.' }
],
'.*': [
{ 'type': 'general', 'pattern': /^[^\.-].*[^\.-]$/, 'message': 'Your domain name shouldn\'t contain . or - at the beginning or the end.' },
{ 'type': 'characters', 'pattern': /^[abcdefghijklmnopqrstwuvxyz0123456789]+$/, 'error': 'Your domain can have at max 26 characters and at least 3.' }
]
};
and tried to use like this:
var validate = new Dictionary<string, dynamic> {
{
@"(\.org|\.info|\.biz|\.name)$",
new {
Type = "size",
Pattern = @"^.{3,64}$",
Message = "Your domain can have at max 26 characters and at least 3."
}
}
};
Where the key of the dynamic object its the regex pattern for the domain extension and the regex inside Pattern
key its the one that should match the domain name.
But I can't figure out how I put 2 validations type inside the dynamic
part of the Dictionary
.
Has anyone did anything like it before or it's stupid and I should do in another way?
The point of doing it this way it's that I can serialize the dictionary as a Json.