-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explore FreeForm validation v2 #989
base: main
Are you sure you want to change the base?
Changes from 1 commit
f61a93d
80a4bb8
9418a35
415abf7
4a523a8
37d4545
00a7af7
f75e407
ac7835f
92b0696
4e021be
9f1b1da
1807098
8076e67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Facet of a constraint mapping creational context which allows to mark the underlying | ||
* element as to be validated in a cascaded way. | ||
* | ||
* @author Gunnar Morling | ||
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI | ||
*/ | ||
public interface Cascadable<C extends Cascadable<C>> { | ||
|
||
/** | ||
* Marks the current element (property, parameter etc.) as cascadable. | ||
* | ||
* @return The current creational context following the method chaining pattern. | ||
*/ | ||
C valid(String mapping); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark about using a String. |
||
|
||
/** | ||
* Adds a group conversion for this cascadable element. Several conversions may be configured for one element. | ||
* | ||
* @param from the source group of the conversion to be configured | ||
* | ||
* @return a creational context allow to set the target group of the conversion | ||
*/ | ||
GroupConversionTargetContext<C> convertGroup(Class<?> from); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* @author Marko Bekhta | ||
*/ | ||
public interface CascadableContainerElementConstraintMappingContext extends ContainerElementConstraintMappingContext, | ||
Cascadable<CascadableContainerElementConstraintMappingContext> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Constraint mapping creational context representing a property of a property holder. Allows | ||
* to place constraints on the property, mark the property as cascadable and to | ||
* navigate to other constraint targets. | ||
* | ||
* @author Gunnar Morling | ||
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI | ||
* @author Marko Bekhta | ||
*/ | ||
public interface CascadablePropertyConstraintMappingContext extends Constrainable<CascadablePropertyConstraintMappingContext>, | ||
PropertyHolderTarget, | ||
PropertyTarget, | ||
Cascadable<CascadablePropertyConstraintMappingContext> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
import org.hibernate.validator.cfg.ConstraintDef; | ||
|
||
/** | ||
* Facet of a property holder constraint mapping creational context which allows to place | ||
* constraints on the underlying element. | ||
* | ||
* @author Gunnar Morling | ||
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI | ||
*/ | ||
public interface Constrainable<C extends Constrainable<C>> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here about it being generic. Maybe |
||
/** | ||
* Adds a new constraint. | ||
* | ||
* @param definition The constraint to add. | ||
* | ||
* @return The current creational context following the method chaining pattern. | ||
*/ | ||
C constraint(ConstraintDef<?, ?> definition); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Constraint mapping creational context representing a type argument of a property, parameter or method return value | ||
* with a generic (return) type. Allows to place constraints on that type argument, mark it as cascadable and to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is far more restricted in the case of a property holder (e.g. no methods for instance) |
||
* navigate to other constraint targets. | ||
* | ||
* @author Gunnar Morling | ||
* @since 6.0 | ||
*/ | ||
public interface ContainerElementConstraintMappingContext extends Constrainable<ContainerElementConstraintMappingContext>, | ||
PropertyTarget, | ||
PropertyHolderTarget, | ||
ContainerElementTarget { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
import org.hibernate.validator.Incubating; | ||
|
||
/** | ||
* Facet of a constraint mapping creational context which allows to select a type argument or the component type of the | ||
* (return) type of the current property as target for the next operations. | ||
* | ||
* @author Marko Bekhta | ||
*/ | ||
@Incubating | ||
public interface ContainerElementTarget { | ||
|
||
ContainerElementConstraintMappingContext containerElementType(Class<?> type); | ||
|
||
ContainerElementConstraintMappingContext containerElementType(Class<?> type, int index, int... nestedIndexes); | ||
|
||
CascadableContainerElementConstraintMappingContext containerElementType(String mapping); | ||
|
||
CascadableContainerElementConstraintMappingContext containerElementType(String mapping, int index, int... nestedIndexes); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Creational context which allows to set the target group of a group conversion configured via | ||
* {@link Cascadable#convertGroup(Class)}. | ||
* | ||
* @author Gunnar Morling | ||
*/ | ||
public interface GroupConversionTargetContext<C> { | ||
|
||
/** | ||
* Sets the target group of the conversion to be configured. | ||
* | ||
* @param to the target group of the conversion | ||
* | ||
* @return The current creational context following the method chaining pattern. | ||
*/ | ||
C to(Class<?> to); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Constraint mapping creational context representing a property of a property holder. Allows | ||
* to place constraints on the property, mark the property as cascadable and to | ||
* navigate to other constraint targets. | ||
* | ||
* @author Gunnar Morling | ||
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI | ||
* @author Marko Bekhta | ||
*/ | ||
public interface PropertyConstraintMappingContext extends Constrainable<PropertyConstraintMappingContext>, | ||
PropertyTarget, | ||
PropertyHolderTarget, | ||
ContainerElementTarget { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Represents a property holder constraint mapping configured via the programmatic API. | ||
* | ||
* @author Marko Bekhta | ||
*/ | ||
public interface PropertyHolderConstraintMapping { | ||
|
||
/** | ||
* Starts defining constraints for the specified unique mapping name. Each mapping name may only be used | ||
* once within all property holder constraint mappings used for configuring one validator factory. | ||
* | ||
* @param propertyHolderMappingName The mapping name for which to define constraints. All constraints | ||
* defined after calling this method are added to the bean of the type {@code beanClass} until the | ||
* next call of {@link this#type(String)}. | ||
* | ||
* @return Instance allowing for defining constraints for the specified property holder mapping name. | ||
*/ | ||
TypeConstraintMappingContext type(String propertyHolderMappingName); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Constraint mapping creational context representing a property of a property holder. Allows | ||
* to place constraints on the property, mark the property as cascadable and to | ||
* navigate to other constraint targets. | ||
* | ||
* @author Gunnar Morling | ||
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI | ||
* @author Marko Bekhta | ||
*/ | ||
public interface PropertyHolderConstraintMappingContext extends Constrainable<PropertyHolderConstraintMappingContext>, | ||
PropertyHolderTarget, | ||
PropertyTarget, | ||
Cascadable<PropertyHolderConstraintMappingContext> { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Facet of a property holder constraint mapping creational context which allows to specify the | ||
* property to which the next operations should be apply. | ||
* | ||
* @author Marko Bekhta | ||
*/ | ||
public interface PropertyHolderTarget { | ||
|
||
/** | ||
* Defines a property, that is a property holder itself, to which the next operations shall apply. | ||
* <p> | ||
* Until this method is called constraints apply on property holder level. After calling this method constraints | ||
* apply on the specified property with the given property type. | ||
* </p> | ||
* <p> | ||
* A given property may only be configured once. | ||
* </p> | ||
* | ||
* @param property The property holder on which to apply the following constraints. | ||
* | ||
* @return A creational context representing the selected property. | ||
*/ | ||
PropertyHolderConstraintMappingContext propertyHolder(String property); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Facet of a property holder constraint mapping creational context which allows to specify the | ||
* property to which the next operations should be apply. | ||
* | ||
* @author Marko Bekhta | ||
*/ | ||
public interface PropertyTarget { | ||
|
||
/** | ||
* Defines a property to which the next operations shall apply. | ||
* <p> | ||
* Until this method is called constraints apply on property holder level. After calling this method constraints | ||
* apply on the specified property with the given property type. | ||
* </p> | ||
* <p> | ||
* A given property may only be configured once. | ||
* </p> | ||
* | ||
* @param property The property on which to apply the following constraints. | ||
* @param propertyType The type of the specified property. | ||
* | ||
* @return A creational context representing the selected property. | ||
*/ | ||
PropertyConstraintMappingContext property(String property, Class<?> propertyType); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; | ||
|
||
/** | ||
* Constraint mapping creational context representing a type. Allows place | ||
* class-level constraints on that type, define its default group sequence (and provider) | ||
* and to navigate to other constraint targets. | ||
* | ||
* @author Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI | ||
* @author Gunnar Morling | ||
*/ | ||
public interface TypeConstraintMappingContext extends PropertyTarget, PropertyHolderTarget { | ||
|
||
/** | ||
* Defines the default group sequence for current type. | ||
* | ||
* @param defaultGroupSequence the default group sequence. | ||
* | ||
* @return The current creational context following the method chaining pattern. | ||
*/ | ||
TypeConstraintMappingContext defaultGroupSequence(Class<?>... defaultGroupSequence); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
|
||
/** | ||
* <p>Contains facet and creational context interfaces forming the API for programmatic constraint | ||
* definition for property holders validation.</p> | ||
* <p>This package is part of the public Hibernate Validator API.</p> | ||
*/ | ||
package org.hibernate.validator.cfg.propertyholder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very generic. Maybe
CascadableProperty
would be better?