All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.willingxyz.restdoc.beanvalidation.NotBlankPostProcessor Maven / Gradle / Ivy

There is a newer version: 0.2.1.4
Show newest version
package cn.willingxyz.restdoc.beanvalidation;

import cn.willingxyz.restdoc.core.models.PropertyModel;
import cn.willingxyz.restdoc.core.parse.postprocessor.IPropertyPostProcessor;
import cn.willingxyz.restdoc.core.parse.utils.TextUtils;
import com.google.auto.service.AutoService;

import javax.validation.constraints.NotBlank;

/**
 * javax.validation.constraints.NotBlank
 */
@AutoService(IPropertyPostProcessor.class)
public class NotBlankPostProcessor extends AbstractBeanValidationPropertyPostProcessor {
    @Override
    public PropertyModel postProcessInternal(PropertyModel propertyModel) {
        NotBlank notBlankAnno = propertyModel.getPropertyItem().getAnnotation(NotBlank.class);
        if (notBlankAnno == null) return propertyModel;


        propertyModel.setRequired(true);
        propertyModel.setDescription(TextUtils.combine(propertyModel.getDescription(), " (值不能仅包含空白字符)"));

        return propertyModel;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy