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

Fix pattern decorator, because the UI expects 'value' instead of 'regexp... #28

Merged
merged 1 commit into from
Apr 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public int size() {
public Object put(String key, Object value) {
return map.put(key, value);
}

public Object remove(String key) {
return map.remove(key);
}

public Object get(String key) {
return map.get(key);
}

private void removeUnusedAttributes(Map<String, Object> annotationAttributes) {
Iterator<String> it = annotationAttributes.keySet().iterator();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.github.valdr.decorator;

import com.github.valdr.ConstraintAttributes;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.github.valdr.ConstraintAttributes;

/**
* Decorates the map of attributes of the {@link javax.validation.constraints.Pattern} constraint.
*/
Expand All @@ -31,12 +32,15 @@ public PatternDecorator(ConstraintAttributes decoratee) {
@Override
public Set<Map.Entry<String, Object>> entrySet() {
Set<Map.Entry<String, Object>> entrySet = getDecoratee().entrySet();
Map<String, Object> result = new HashMap<>();
for (Map.Entry<String, Object> entry : entrySet) {
if ("regexp".equals(entry.getKey())) {
entry.setValue(javaToJavaScriptRegexpPattern(entry));
result.put("value", javaToJavaScriptRegexpPattern(entry));
} else {
result.put(entry.getKey(), entry.getValue());
}
}
return entrySet;
return result.entrySet();
}

private String javaToJavaScriptRegexpPattern(Map.Entry<String, Object> entry) {
Expand Down