public async Task FindOrCreateFromJson() { await _emTask; var vr = new RequiredValidator(); var vrNode = ((IJsonSerializable) vr).ToJNode(null); var vr2 = Validator.FindOrCreate(vrNode); var vr3 = Validator.FindOrCreate(vrNode); Assert.IsTrue(vr2 == vr3); var mlVr = new MaxLengthValidator(17); var mlVrNode = ((IJsonSerializable)mlVr).ToJNode(null); var mlVr2 = Validator.FindOrCreate(mlVrNode); var mlVr3 = Validator.FindOrCreate(mlVrNode); Assert.IsTrue(mlVr2 == mlVr3); }
public async Task InternValidators() { await _emTask; var vr2 = new RequiredValidator().Intern(); var vr3 = new RequiredValidator().Intern(); Assert.IsTrue(vr2 == vr3); Assert.IsTrue(vr2.Equals(vr3)); var mlVr2 = new MaxLengthValidator(17).Intern(); var mlVr3 = new MaxLengthValidator(17).Intern(); Assert.IsTrue(mlVr2 == mlVr3); Assert.IsTrue(mlVr2.Equals(mlVr3)); var slVr2 = new StringLengthValidator(3, 12).Intern(); var slVr3 = new StringLengthValidator(3, 12).Intern(); Assert.IsTrue(slVr2 == slVr3); Assert.IsTrue(slVr2.Equals(slVr3)); }
public async Task InternValidators() { var em1 = await TestFns.NewEm(_serviceName); var vr2 = new RequiredValidator().Intern(); var vr3 = new RequiredValidator().Intern(); Assert.IsTrue(vr2 == vr3); Assert.IsTrue(vr2.Equals(vr3)); var mlVr2 = new MaxLengthValidator(17).Intern(); var mlVr3 = new MaxLengthValidator(17).Intern(); Assert.IsTrue(mlVr2 == mlVr3); Assert.IsTrue(mlVr2.Equals(mlVr3)); var slVr2 = new StringLengthValidator(3, 12).Intern(); var slVr3 = new StringLengthValidator(3, 12).Intern(); Assert.IsTrue(slVr2 == slVr3); Assert.IsTrue(slVr2.Equals(slVr3)); }
private Validator BuildValidator(Dictionary <string, object> data) { var name = data["name"]; Validator v; if (name as string == "required") { v = new RequiredValidator(); } else if (name as string == "maxLength") { v = new MaxLengthValidator(); } else { v = new Validator(); } v.name = name.ToString(); if (data.Count > 1) { v.properties = data; } return(v); }
public async Task FindOrCreateFromJson() { var em1 = await TestFns.NewEm(_serviceName); var vr = new RequiredValidator(); var vrNode = ((IJsonSerializable) vr).ToJNode(null); var vr2 = Validator.FindOrCreate(vrNode); var vr3 = Validator.FindOrCreate(vrNode); Assert.IsTrue(vr2 == vr3); var mlVr = new MaxLengthValidator(17); var mlVrNode = ((IJsonSerializable) mlVr).ToJNode(null); var mlVr2 = Validator.FindOrCreate(mlVrNode); var mlVr3 = Validator.FindOrCreate(mlVrNode); Assert.IsTrue(mlVr2 == mlVr3); }
private Validator BuildValidator(Dictionary<string, string> data) { var name = data["name"]; Validator v; if (name == "required") v = new RequiredValidator(); else if (name == "maxLength") v = new MaxLengthValidator(); else v = new Validator(); v.name = name; if (data.Count > 1) { v.properties = data; } return v; }
public static IRuleBuilder <T> MaxLength <T>(this IRuleBuilder <T> ruleBuilder, int maxLength) where T : class { ruleBuilder.AddRule(MaxLengthValidator <T> .New(ruleBuilder, maxLength)); return(ruleBuilder); }
public DapperImplementor(ISqlGenerator sqlGenerator) { SqlGenerator = sqlGenerator; _maxLengthValidator = new MaxLengthValidator(); }