@Override public Integer getMinLength() { if (header instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) header).minLength(); } return null; }
@Override public Integer getMinLength() { if (queryParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) queryParameter).minLength(); } return null; }
@Override public Integer getMinLength() { if (uriParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) uriParameter).minLength(); } return null; }
@Override public Integer getMinLength() { if (formParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) formParameter).minLength(); } return null; }
private void addFacetsForString(FieldSpec.Builder typeSpec, StringTypeDeclaration typeDeclaration) { AnnotationSpec.Builder minMax = null; if (typeDeclaration.minLength() != null) { minMax = AnnotationSpec.builder(Size.class).addMember("min", "$L", typeDeclaration.minLength()); } if (typeDeclaration.maxLength() != null) { if (minMax == null) { minMax = AnnotationSpec.builder(Size.class).addMember("max", "$L", typeDeclaration.maxLength()); } else { minMax.addMember("max", "$L", typeDeclaration.maxLength()); } } if (minMax != null) { typeSpec.addAnnotation(minMax.build()); } }
validations.withLenghts(stringType.minLength(), stringType.maxLength());
private void addFacetsForString(FieldSpec.Builder typeSpec, StringTypeDeclaration typeDeclaration) { AnnotationSpec.Builder minMax = null; if (typeDeclaration.minLength() != null) { minMax = AnnotationSpec.builder(Size.class).addMember("min", "$L", typeDeclaration.minLength()); } if (typeDeclaration.maxLength() != null) { if (minMax == null) { minMax = AnnotationSpec.builder(Size.class).addMember("max", "$L", typeDeclaration.maxLength()); } else { minMax.addMember("max", "$L", typeDeclaration.maxLength()); } } if (minMax != null) { typeSpec.addAnnotation(minMax.build()); } if ( typeDeclaration.pattern() != null ) { typeSpec.addAnnotation(AnnotationSpec.builder(Pattern.class).addMember("regexp", "$S", EcmaPattern.fromString(typeDeclaration.pattern()).asJavaPattern()).build()); } }