com.github.valdr:valdr-bean-validation

Bean Validation (JSR 303/349) plugin for valdr, the new AngularJS Model Validator.

Лицензия

Лицензия

Группа

Группа

com.github.valdr
Идентификатор

Идентификатор

valdr-bean-validation
Последняя версия

Последняя версия

1.1.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

Bean Validation (JSR 303/349) plugin for valdr, the new AngularJS Model Validator.

Скачать valdr-bean-validation

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.valdr/valdr-bean-validation/ -->
<dependency>
    <groupId>com.github.valdr</groupId>
    <artifactId>valdr-bean-validation</artifactId>
    <version>1.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.valdr/valdr-bean-validation/
implementation 'com.github.valdr:valdr-bean-validation:1.1.3'
// https://jarcasting.com/artifacts/com.github.valdr/valdr-bean-validation/
implementation ("com.github.valdr:valdr-bean-validation:1.1.3")
'com.github.valdr:valdr-bean-validation:jar:1.1.3'
<dependency org="com.github.valdr" name="valdr-bean-validation" rev="1.1.3">
  <artifact name="valdr-bean-validation" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.valdr', module='valdr-bean-validation', version='1.1.3')
)
libraryDependencies += "com.github.valdr" % "valdr-bean-validation" % "1.1.3"
[com.github.valdr/valdr-bean-validation "1.1.3"]

Зависимости

compile (9)

Идентификатор библиотеки Тип Версия
org.slf4j : slf4j-api jar 1.7.9
org.reflections : reflections jar 0.9.9
javax.validation : validation-api jar 2.0.1.Final
com.fasterxml.jackson.core : jackson-databind jar 2.9.5
com.google.guava : guava jar 23.0
org.apache.commons : commons-lang3 jar 3.7
commons-cli : commons-cli jar 1.4
commons-io : commons-io jar 2.6
org.hibernate.validator : hibernate-validator jar 6.0.9.Final

provided (2)

Идентификатор библиотеки Тип Версия
javax.servlet : javax.servlet-api jar 4.0.0
org.projectlombok : lombok jar 1.16.20

test (7)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.springframework : spring-test jar 5.0.5.RELEASE
org.springframework : spring-web jar 5.0.5.RELEASE
org.slf4j : slf4j-simple jar 1.7.9
org.hamcrest : hamcrest-library jar 1.3
org.mockito : mockito-core jar 2.18.3
org.hibernate.javax.persistence : hibernate-jpa-2.1-api jar 1.0.2

Модули Проекта

Данный проект не имеет модулей.

valdr Bean Validation

Build Status Coverage Status Maven Central License

Bean Validation (JSR 303) plugin for valdr, the new AngularJS Model Validator.

Offering

valdr Bean Validation parses Java model classes for Bean Validation constraints (aka JSR 303 annotations) and extracts their information into a JSON document to be used by valdr. This allows to apply the exact same validation rules on the server and on the AngularJS client.

Features

  • offline use: CLI client which can be integrated into build process to produce static valdr JSON which is packaged and delivered with the web application
  • online use: Servlet which parses model classes at runtime and sends JSON back to AngularJS client (e.g. during client start or on-demand)
  • both Servlet and CLI client support a number of config options
    • list of packages to scan
    • list of classes in those packages to exclude
    • list of fields to exclude
    • list of custom annotation classes to include in JSON
    • whether to output simple or full type names
    • the output file name (CLI only)
    • CORS Access-Control-Allow-Origin HTTP header value (Servlet only)
  • Servlet offers built-in CORS support

Use

Check out the demo for usage samples of both CLI client and Servlet.

<dependency>
  <groupId>com.github.valdr</groupId>
  <artifactId>valdr-bean-validation</artifactId>
  <version>see-latest-version-at-the-top-of-this-page</version>
</dependency>

CLI client

Example of Maven integration:

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>${exec-maven-plugin.version}</version>
      <executions>
        <execution>
          <id>process-bean-validation-annotations</id>
          <phase>process-classes</phase>
          <goals>
            <goal>java</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <mainClass>com.github.valdr.cli.ValdrBeanValidation</mainClass>
        <arguments>
          <!-- optional, if omitted valdr-bean-validation.json is expected at the root of the class path -->
          <argument>-cf</argument>
          <argument>my-config.json</argument>
          <!-- optional, overrides any 'outputFile' which may have been set in the above config file -->
          <argument>-outputFile</argument>
          <argument>${basedir}/src/main/webapp/validation/validation.json</argument>
        </arguments>
      </configuration>
    </plugin>
  </plugins>
</build>

Servlet

Example of web.xml:

<servlet>
  <servlet-name>valdr Bean Validation Servlet</servlet-name>
  <servlet-class>com.github.valdr.ValidationRulesServlet</servlet-class>
  <!-- if omitted valdr-bean-validation.json is expected at the root of the class path -->
  <init-param>
    <param-name>configFile</param-name>
    <param-value>my-config.json</param-value>
  </init-param>
</servlet>

Dependency on valdr

valdr Bean Validation is dependent on valdr in two ways:

To indicate which valdr version a specific valdr Bean Validation version supports there's a simple rule: the first digit of the valdr Bean Validation version denotes the supported valdr version. Version 1.x will support valdr 1. This means that valdr Bean Validation 1.x+1 may introduce breaking changes over 1.x because the second version digit kind-of represents the "major" version.

Mapping of Bean Validation constraints to valdr constraints

The BuiltInConstraint.java enum defines the mapping of Bean Validation constraints to valdr constraints.

Bean Validation valdr Comment
NotNull required
Min min
Max max
Size size
Digits digits
Pattern pattern Java regex pattern is transformed to JavaScript pattern
Future future
Past past
Email email
URL url proprietary Hibernate Validator (not in Bean Validation spec)

Support

Ask a question on Stack Overflow and tag it with valdr-bean-validation.

License

MIT © Netcetera AG

com.github.valdr

Netcetera

Software matters

Версии библиотеки

Версия
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0
1.0.0-rc3
1.0.0-rc2