Skip to content
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

Apply size methods to String #1057

Open
acktsap opened this issue Sep 27, 2024 · 1 comment
Open

Apply size methods to String #1057

acktsap opened this issue Sep 27, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@acktsap
Copy link
Contributor

acktsap commented Sep 27, 2024

Describe the feature you request

giveMeBuilder#size methods not applied to String class.

For example, folowing code produces arbitrary size of string.

data class A(val a: String)

val value = fixtureMonkey.giveMeBuilder<A>()
    .size(A::a, 10)
    .sample()
println(value.a.length)

(Optional): Suggest A Solution

If would be nice to produce string with the size i provided.

If the feature request is approved, would you be willing to submit a PR?

Yes

@acktsap acktsap added the enhancement New feature or request label Sep 27, 2024
@acktsap acktsap changed the title Take minSize as Apply size methods to string Sep 27, 2024
@acktsap acktsap changed the title Apply size methods to string Apply size methods to String Sep 27, 2024
@seongahjo
Copy link
Contributor

seongahjo commented Sep 28, 2024

I think this is a good feature to keep consistency with the @Size annotation.

@Target(value={METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER})
 @Retention(value=RUNTIME)
 @Documented
 @Constraint(validatedBy={})
public @interface Size
The annotated element size must be between the specified boundaries (included).
Supported types are:

CharSequence (length of character sequence is evaluated)
Collection (collection size is evaluated)
Map (map size is evaluated)
Array (array length is evaluated)
null elements are considered valid.

It would be nice to work on the CharSequence interface if we go further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants